add fsync warning

This commit is contained in:
Michael Eischer 2022-12-02 21:08:15 +01:00
parent 408dcab92e
commit 80babf98e7

View file

@ -16,6 +16,7 @@ import (
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
"sync"
"syscall" "syscall"
"time" "time"
@ -73,6 +74,8 @@ func New(path string, opt Options) (*Handler, error) {
type Handler struct { type Handler struct {
path string // filesystem path of repo path string // filesystem path of repo
opt Options opt Options
fsyncWarning sync.Once
} }
// httpDefaultError write a HTTP error with the default description // httpDefaultError write a HTTP error with the default description
@ -633,6 +636,9 @@ func (h *Handler) saveBlob(w http.ResponseWriter, r *http.Request) {
h.internalServerError(w, err) h.internalServerError(w, err)
return return
} }
h.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.")
})
} }
h.sendMetric(objectType, BlobWrite, uint64(written)) h.sendMetric(objectType, BlobWrite, uint64(written))