Refactoring code

Take all the storing stuff out of upload file
This commit is contained in:
Las Zenow 2012-10-28 17:04:38 +01:00
parent 9c28f8926f
commit 85111946ed
3 changed files with 226 additions and 213 deletions

View file

@ -5,7 +5,6 @@ import (
"net/http"
"os"
"os/exec"
"strconv"
"strings"
)
@ -162,19 +161,6 @@ func newHandler(w http.ResponseWriter, r *http.Request) {
loadTemplate(w, "new", data)
}
func ValidFileName(path string, title string, extension string) string {
title = strings.Replace(title, "/", "_", -1)
title = strings.Replace(title, "?", "_", -1)
title = strings.Replace(title, "#", "_", -1)
file := path + "/" + title + extension
_, err := os.Stat(file)
for i := 0; err == nil; i++ {
file = path + "/" + title + "_" + strconv.Itoa(i) + extension
_, err = os.Stat(file)
}
return file
}
func storeHandler(w http.ResponseWriter, r *http.Request) {
sess := GetSession(r)
if sess.User == "" {