[#98] fstree: Do not fail iteration over just removed files

A directory is read and files are saved to a local variable. The iteration
over such files may lead to a non-existing files reading due to a normal SN
operation cycle and, therefore, may lead to a returning the OS error to a
caller. Skip just removed (or lost) files as the golang std library does in
similar situations:
5f1a0320b9/src/os/dir_unix.go (L128-L133).

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
Pavel Karpy 2023-03-21 21:31:48 +03:00
parent db3ccd2762
commit edd4c7be13
2 changed files with 7 additions and 3 deletions

View file

@ -50,6 +50,7 @@ Changelog for FrostFS Node
- Actually use `object.put.pool_size_local` and independent pool for local puts (#64).
- Pretty printer of basic ACL in the NeoFS CLI (#2259)
- Adding of public key for nns group `group.frostfs` at init step (#130)
- Iterating over just removed files by FSTree (#98)
### Removed
### Updated

View file

@ -135,13 +135,16 @@ func (t *FSTree) iterate(depth uint64, curPath []string, prm common.IteratePrm)
continue
}
data, err := os.ReadFile(filepath.Join(curPath...))
if err != nil && os.IsNotExist(err) {
continue
}
if prm.LazyHandler != nil {
err = prm.LazyHandler(addr, func() ([]byte, error) {
return os.ReadFile(filepath.Join(curPath...))
return data, err
})
} else {
var data []byte
data, err = os.ReadFile(filepath.Join(curPath...))
if err == nil {
data, err = t.Decompress(data)
}