lib/fs: consistency renaming SyncPath -> MustSyncPath, since it doesnt return error

This commit is contained in:
Aliaksandr Valialkin 2019-06-11 23:13:04 +03:00
parent 3dd36b8088
commit 935bfd7a18
7 changed files with 27 additions and 27 deletions

View file

@ -72,8 +72,8 @@ var (
readersCount = metrics.NewCounter(`vm_fs_readers`)
)
// SyncPath syncs contents of the given path.
func SyncPath(path string) {
// MustSyncPath syncs contents of the given path.
func MustSyncPath(path string) {
d, err := os.Open(path)
if err != nil {
logger.Panicf("FATAL: cannot open %q: %s", path, err)
@ -114,7 +114,7 @@ func WriteFile(path string, data []byte) error {
return fmt.Errorf("cannot obtain absolute path to %q: %s", path, err)
}
parentDirPath := filepath.Dir(absPath)
SyncPath(parentDirPath)
MustSyncPath(parentDirPath)
return nil
}
@ -144,7 +144,7 @@ func mkdirSync(path string) error {
// Sync the parent directory, so the created directory becomes visible
// in the fs after power loss.
parentDirPath := filepath.Dir(path)
SyncPath(parentDirPath)
MustSyncPath(parentDirPath)
return nil
}
@ -176,7 +176,7 @@ func RemoveDirContents(dir string) {
logger.Panicf("FATAL: cannot remove %q: %s", fullPath, err)
}
}
SyncPath(dir)
MustSyncPath(dir)
}
// MustClose must close the given file f.
@ -203,7 +203,7 @@ func IsPathExist(path string) bool {
func MustRemoveAllSynced(path string) {
MustRemoveAll(path)
parentDirPath := filepath.Dir(path)
SyncPath(parentDirPath)
MustSyncPath(parentDirPath)
}
// MustRemoveAll removes path with all the contents.
@ -297,7 +297,7 @@ func HardLinkFiles(srcDir, dstDir string) error {
}
}
SyncPath(dstDir)
MustSyncPath(dstDir)
return nil
}

View file

@ -154,7 +154,7 @@ func (bsw *blockStreamWriter) MustClose() {
// Sync bsw.path contents to make sure it doesn't disappear
// after system crash or power loss.
if bsw.path != "" {
fs.SyncPath(bsw.path)
fs.MustSyncPath(bsw.path)
}
bsw.reset()

View file

@ -861,7 +861,7 @@ func openParts(path string) ([]*partWrapper, error) {
return nil, fmt.Errorf("cannot create %q: %s", tmpDir, err)
}
fs.SyncPath(path)
fs.MustSyncPath(path)
// Open parts.
fis, err := d.Readdir(-1)
@ -965,9 +965,9 @@ func (tb *Table) CreateSnapshotAt(dstDir string) error {
}
}
fs.SyncPath(dstDir)
fs.MustSyncPath(dstDir)
parentDir := filepath.Dir(dstDir)
fs.SyncPath(parentDir)
fs.MustSyncPath(parentDir)
logger.Infof("created Table snapshot of %q at %q in %s", srcDir, dstDir, time.Since(startTime))
return nil
@ -1061,7 +1061,7 @@ func runTransaction(txnLock *sync.RWMutex, pathPrefix, txnPath string) error {
}
// Flush pathPrefix directory metadata to the underying storage.
fs.SyncPath(pathPrefix)
fs.MustSyncPath(pathPrefix)
// Remove the transaction file.
if err := os.Remove(txnPath); err != nil {

View file

@ -149,7 +149,7 @@ func (bsw *blockStreamWriter) MustClose() {
// Sync bsw.path contents to make sure it doesn't disappear
// after system crash or power loss.
if bsw.path != "" {
fs.SyncPath(bsw.path)
fs.MustSyncPath(bsw.path)
}
bsw.reset()

View file

@ -1342,8 +1342,8 @@ func (pt *partition) createSnapshot(srcDir, dstDir string) error {
}
}
fs.SyncPath(dstDir)
fs.SyncPath(filepath.Dir(dstDir))
fs.MustSyncPath(dstDir)
fs.MustSyncPath(filepath.Dir(dstDir))
return nil
}
@ -1444,8 +1444,8 @@ func runTransaction(txnLock *sync.RWMutex, pathPrefix1, pathPrefix2, txnPath str
}
// Flush pathPrefix* directory metadata to the underying storage.
fs.SyncPath(pathPrefix1)
fs.SyncPath(pathPrefix2)
fs.MustSyncPath(pathPrefix1)
fs.MustSyncPath(pathPrefix2)
// Remove the transaction file.
if err := os.Remove(txnPath); err != nil {
@ -1487,6 +1487,6 @@ func createPartitionDirs(path string) error {
if err := fs.MkdirAllFailIfExist(tmpPath); err != nil {
return fmt.Errorf("cannot create tmp directory %q: %s", tmpPath, err)
}
fs.SyncPath(path)
fs.MustSyncPath(path)
return nil
}

View file

@ -181,7 +181,7 @@ func (s *Storage) CreateSnapshot() (string, error) {
if err := fs.SymlinkRelative(bigDir, dstBigDir); err != nil {
return "", fmt.Errorf("cannot create symlink from %q to %q: %s", bigDir, dstBigDir, err)
}
fs.SyncPath(dstDataDir)
fs.MustSyncPath(dstDataDir)
idbSnapshot := fmt.Sprintf("%s/indexdb/snapshots/%s", s.path, snapshotName)
idb := s.idb()
@ -201,8 +201,8 @@ func (s *Storage) CreateSnapshot() (string, error) {
return "", fmt.Errorf("cannot create symlink from %q to %q: %s", idbSnapshot, dstIdbDir, err)
}
fs.SyncPath(dstDir)
fs.SyncPath(srcDir + "/snapshots")
fs.MustSyncPath(dstDir)
fs.MustSyncPath(srcDir + "/snapshots")
logger.Infof("created Storage snapshot for %q at %q in %s", srcDir, dstDir, time.Since(startTime))
return snapshotName, nil
@ -401,7 +401,7 @@ func (s *Storage) mustRotateIndexDB() {
s.idbCurr.Store(idbNew)
// Persist changes on the file system.
fs.SyncPath(s.path)
fs.MustSyncPath(s.path)
// Flush tsidCache, so idbNew can be populated with fresh data.
s.tsidCache.Reset()
@ -900,7 +900,7 @@ func openIndexDBTables(path string, metricIDCache, metricNameCache *fastcache.Ca
}
// Persist changes on the file system.
fs.SyncPath(path)
fs.MustSyncPath(path)
// Open the last two tables.
currPath := path + "/" + tableNames[len(tableNames)-1]

View file

@ -164,10 +164,10 @@ func (tb *table) CreateSnapshot(snapshotName string) (string, string, error) {
}
}
fs.SyncPath(dstSmallDir)
fs.SyncPath(dstBigDir)
fs.SyncPath(filepath.Dir(dstSmallDir))
fs.SyncPath(filepath.Dir(dstBigDir))
fs.MustSyncPath(dstSmallDir)
fs.MustSyncPath(dstBigDir)
fs.MustSyncPath(filepath.Dir(dstSmallDir))
fs.MustSyncPath(filepath.Dir(dstBigDir))
logger.Infof("created table snapshot for %q at (%q, %q) in %s", tb.path, dstSmallDir, dstBigDir, time.Since(startTime))
return dstSmallDir, dstBigDir, nil