storage/filestore: Ignore IsNotExist error walking files
A file piece could be deleted in between walking the list of files read from a directory and before we actually perform any operation on such file. When that happens, we don't want to return an error, we want to just ignore it and carry on. Change-Id: I8f6986070e5883599a08fccf8b125c075b30fe1b
This commit is contained in:
parent
3b4b5f45c7
commit
ed9816fd30
@ -701,12 +701,17 @@ func walkNamespaceWithPrefix(ctx context.Context, log *zap.Logger, namespace []b
|
||||
for _, name := range names {
|
||||
info, err := os.Lstat(keyDir + "/" + name)
|
||||
if err != nil {
|
||||
if pErr, ok := err.(*os.PathError); ok {
|
||||
if pErr.Err.Error() == "lstat" {
|
||||
log.Error("Unable to read the disk, please verify the disk is not corrupt")
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
return err
|
||||
|
||||
// convert to lowercase the perr.Op because Go reports inconsistently
|
||||
// "lstat" in Linux and "Lstat" in Windows
|
||||
if perr, ok := err.(*os.PathError); ok && strings.ToLower(perr.Op) == "lstat" {
|
||||
log.Error("Unable to read the disk, please verify the disk is not corrupt")
|
||||
}
|
||||
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
if info.Mode().IsDir() {
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user