/*
GoCheese -- Python private package repository and caching proxy
-Copyright (C) 2019 Sergey Matveev <stargrave@stargrave.org>
- 2019 Elena Balakhonova <balakhonova_e@riseup.net>
+Copyright (C) 2019-2021 Sergey Matveev <stargrave@stargrave.org>
+ 2019-2021 Elena Balakhonova <balakhonova_e@riseup.net>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
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)
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)