lib/{storage,mergeset}: create missing partition directories after restoring from backups

Backup tools could skip empty directories. So re-create such directories on the first run.
This commit is contained in:
Aliaksandr Valialkin 2019-11-02 02:26:02 +02:00
parent 5d439cc6f2
commit 26ffc77622
2 changed files with 8 additions and 2 deletions

View File

@ -911,7 +911,10 @@ var mergeWorkersCount = func() int {
}()
func openParts(path string) ([]*partWrapper, error) {
// Verify that the directory for the parts exists.
// The path can be missing after restoring from backup, so create it if needed.
if err := fs.MkdirAllIfNotExist(path); err != nil {
return nil, err
}
d, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("cannot open difrectory: %s", err)

View File

@ -1253,7 +1253,10 @@ func appendPartsToMerge(dst, src []*partWrapper, maxPartsToMerge int, maxRows ui
}
func openParts(pathPrefix1, pathPrefix2, path string) ([]*partWrapper, error) {
// Verify that the directory for the parts exists.
// The path can be missing after restoring from backup, so create it if needed.
if err := fs.MkdirAllIfNotExist(path); err != nil {
return nil, err
}
d, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("cannot open directory %q: %s", path, err)