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