lib/fs: convert CreateFlockFile to MustCreateFlockFile

Callers of CreateFlockFile log the returned err and exit.
It is better to log the error inside the MustCreateFlockFile together with the path
to the specified directory and the call stack. This simplifies
the code at the callers' side while leaving the debuggability at the same level.
This commit is contained in:
Aliaksandr Valialkin
2023-04-14 19:49:54 -07:00
parent c0b852d50d
commit 2a3b19e1d2
6 changed files with 14 additions and 34 deletions

View File

@@ -144,14 +144,6 @@ func mustOpenInternal(path, name string, chunkFileSize, maxBlockSize, maxPending
return q
}
func mustCreateFlockFile(path string) *os.File {
f, err := fs.CreateFlockFile(path)
if err != nil {
logger.Panicf("FATAL: %s", err)
}
return f
}
func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingBytes uint64) (*queue, error) {
// Protect from concurrent opens.
var q queue
@@ -178,7 +170,7 @@ func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingB
}
fs.MustMkdirIfNotExist(path)
q.flockF = mustCreateFlockFile(path)
q.flockF = fs.MustCreateFlockFile(path)
mustCloseFlockF := true
defer func() {
if mustCloseFlockF {