[#1686] fstree: Return proper error for concurrent Delete

If the file doesn't exist, return `apistatus.ObjectNotFound`.
First check is still there as a shortcut.

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-08-23 15:44:51 +03:00 committed by fyrchik
parent 0b95a21701
commit 6c2d3b020f

View file

@ -191,7 +191,11 @@ func (t *FSTree) Delete(prm common.DeletePrm) (common.DeleteRes, error) {
return common.DeleteRes{}, err return common.DeleteRes{}, err
} }
return common.DeleteRes{}, os.Remove(p) err = os.Remove(p)
if err != nil && os.IsNotExist(err) {
err = apistatus.ObjectNotFound{}
}
return common.DeleteRes{}, err
} }
// Exists returns the path to the file with object contents if it exists in the storage // Exists returns the path to the file with object contents if it exists in the storage