X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=upload.go;h=cd98df5ba5954db50c2889393c882c3b77be4994;hb=37facf3dde161d2df4d430896dc87ebb5740cc64;hp=e46fa6db619715d3ecd85833648f120aeeedcdc4;hpb=cb0449b3d3da2498e360098694a556c882d454bd;p=gocheese.git diff --git a/upload.go b/upload.go index e46fa6d..cd98df5 100644 --- a/upload.go +++ b/upload.go @@ -39,7 +39,9 @@ func serveUpload(w http.ResponseWriter, r *http.Request) { http.Error(w, "unauthenticated", http.StatusUnauthorized) return } - auther, ok := passwords[username] + PasswordsM.RLock() + auther, ok := Passwords[username] + PasswordsM.RUnlock() if !ok || !auther.Auth(password) { log.Println(r.RemoteAddr, "unauthenticated", username) http.Error(w, "unauthenticated", http.StatusUnauthorized) @@ -119,12 +121,14 @@ func serveUpload(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - if err = dst.Sync(); err != nil { - log.Println("error", r.RemoteAddr, filename, err) - os.Remove(dst.Name()) - dst.Close() - http.Error(w, err.Error(), http.StatusInternalServerError) - return + if !NoSync { + if err = dst.Sync(); err != nil { + log.Println("error", r.RemoteAddr, filename, err) + os.Remove(dst.Name()) + dst.Close() + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } } dst.Close() digest := hasher.Sum(nil)