forked from TrueCloudLab/frostfs-node
[#1226] blobovniczatree: Delete fix db extensions in Init()
Since several releases have been released, this code is not relevant. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
78b1d9b18d
commit
62cbb72a5e
3 changed files with 0 additions and 116 deletions
|
@ -2,10 +2,6 @@ package blobovniczatree
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
|
@ -14,8 +10,6 @@ import (
|
|||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
var errFailedToChangeExtensionReadOnly = errors.New("failed to change blobovnicza extension: read only mode")
|
||||
|
||||
// Open opens blobovnicza tree.
|
||||
func (b *Blobovniczas) Open(mode mode.ComponentMode) error {
|
||||
b.readOnly = mode.ReadOnly()
|
||||
|
@ -31,13 +25,6 @@ func (b *Blobovniczas) Open(mode mode.ComponentMode) error {
|
|||
func (b *Blobovniczas) Init() error {
|
||||
b.log.Debug(logs.BlobovniczatreeInitializingBlobovniczas)
|
||||
|
||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensions)
|
||||
if err := b.addDBExtensionToDBs(b.rootPath, 0); err != nil {
|
||||
b.log.Error(logs.BlobovniczaTreeFixingFileExtensionsFailed, zap.Error(err))
|
||||
return err
|
||||
}
|
||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensionsCompletedSuccessfully)
|
||||
|
||||
if b.readOnly {
|
||||
b.log.Debug(logs.BlobovniczatreeReadonlyModeSkipBlobovniczasInitialization)
|
||||
return nil
|
||||
|
@ -111,37 +98,3 @@ func (b *Blobovniczas) getBlobovnicza(p string) *sharedDB {
|
|||
func (b *Blobovniczas) getBlobovniczaWithoutCaching(p string) *sharedDB {
|
||||
return b.commondbManager.GetByPath(p)
|
||||
}
|
||||
|
||||
func (b *Blobovniczas) addDBExtensionToDBs(path string, depth uint64) error {
|
||||
entries, err := os.ReadDir(path)
|
||||
if os.IsNotExist(err) && depth == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() {
|
||||
if err := b.addDBExtensionToDBs(filepath.Join(path, entry.Name()), depth+1); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.HasSuffix(entry.Name(), dbExtension) {
|
||||
continue
|
||||
}
|
||||
if b.readOnly {
|
||||
return errFailedToChangeExtensionReadOnly
|
||||
}
|
||||
|
||||
sourcePath := filepath.Join(path, entry.Name())
|
||||
targetPath := filepath.Join(path, entry.Name()+dbExtension)
|
||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensionForFile, zap.String("source", sourcePath), zap.String("target", targetPath))
|
||||
if err := os.Rename(sourcePath, targetPath); err != nil {
|
||||
b.log.Error(logs.BlobovniczaTreeFixingFileExtensionFailed, zap.String("source", sourcePath), zap.String("target", targetPath), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensionCompletedSuccessfully, zap.String("source", sourcePath), zap.String("target", targetPath))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue