mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
Print fsync warning only once
The repo.Handler is freshly instantiated for every request such that it forget that the fsync warning was already printed. Use a single instance in the Server instead.
This commit is contained in:
parent
b2e8044fbd
commit
be14687a9c
2 changed files with 5 additions and 3 deletions
|
@ -39,6 +39,7 @@ type Options struct {
|
|||
|
||||
BlobMetricFunc BlobMetricFunc
|
||||
QuotaManager *quota.Manager
|
||||
FsyncWarning *sync.Once
|
||||
}
|
||||
|
||||
// DefaultDirMode is the file mode used for directory creation if not
|
||||
|
@ -74,8 +75,6 @@ func New(path string, opt Options) (*Handler, error) {
|
|||
type Handler struct {
|
||||
path string // filesystem path of repo
|
||||
opt Options
|
||||
|
||||
fsyncWarning sync.Once
|
||||
}
|
||||
|
||||
// httpDefaultError write a HTTP error with the default description
|
||||
|
@ -639,7 +638,7 @@ func (h *Handler) saveBlob(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if syncNotSup {
|
||||
h.fsyncWarning.Do(func() {
|
||||
h.opt.FsyncWarning.Do(func() {
|
||||
log.Print("WARNING: fsync is not supported by the data storage. This can lead to data loss, if the system crashes or the storage is unexpectedly disconnected.")
|
||||
})
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue