Refactoring code
Take all the storing stuff out of upload file
This commit is contained in:
parent
9c28f8926f
commit
85111946ed
3 changed files with 226 additions and 213 deletions
14
admin.go
14
admin.go
|
@ -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 == "" {
|
||||
|
|
Reference in a new issue