From 6c2d3b020f2b5dac805e73f0ef8daec20c84f179 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 23 Aug 2022 15:44:51 +0300 Subject: [PATCH] [#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 --- pkg/local_object_storage/blobstor/fstree/fstree.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index 61d66aa0..6f962693 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -191,7 +191,11 @@ func (t *FSTree) Delete(prm common.DeletePrm) (common.DeleteRes, error) { 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