2022-07-08 14:33:49 +03:00
|
|
|
package fstree
|
|
|
|
|
2022-07-11 15:34:17 +03:00
|
|
|
import (
|
2024-06-04 16:28:47 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
2023-03-07 16:38:26 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
2022-07-11 15:34:17 +03:00
|
|
|
)
|
|
|
|
|
2022-07-08 14:33:49 +03:00
|
|
|
// Open implements common.Storage.
|
2024-06-04 16:28:47 +03:00
|
|
|
func (t *FSTree) Open(mode mode.ComponentMode) error {
|
|
|
|
t.readOnly = mode.ReadOnly()
|
|
|
|
t.metrics.SetMode(mode)
|
2022-08-23 16:04:01 +03:00
|
|
|
return nil
|
|
|
|
}
|
2022-07-08 14:33:49 +03:00
|
|
|
|
|
|
|
// Init implements common.Storage.
|
2022-07-11 15:34:17 +03:00
|
|
|
func (t *FSTree) Init() error {
|
2023-08-11 11:32:43 +03:00
|
|
|
if err := util.MkdirAllX(t.RootPath, t.Permissions); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-08 11:57:23 +03:00
|
|
|
if !t.readOnly {
|
|
|
|
f := newSpecificWriteData(t.fileCounter, t.RootPath, t.Permissions, t.noSync)
|
|
|
|
if f != nil {
|
2024-02-08 17:53:27 +03:00
|
|
|
t.writer = f
|
2024-02-08 11:57:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-11 11:32:43 +03:00
|
|
|
return t.initFileCounter()
|
2022-07-11 15:34:17 +03:00
|
|
|
}
|
2022-07-08 14:33:49 +03:00
|
|
|
|
|
|
|
// Close implements common.Storage.
|
2023-06-02 16:04:02 +03:00
|
|
|
func (t *FSTree) Close() error {
|
|
|
|
t.metrics.Close()
|
|
|
|
return nil
|
|
|
|
}
|