backends: make NewObject return fs.ErrorIsDir if possible

This changes the interface to NewObject so that if NewObject is called
on a directory then it should return fs.ErrorIsDir if possible without
doing any extra work, otherwise fs.ErrorObjectNotFound.

Tested on integration test server with:

go run integration-test.go -tests backend -run TestIntegration/FsMkdir/FsPutFiles/FsNewObjectDir -branch fix-stat -maxtries 1
This commit is contained in:
Nick Craig-Wood
2021-10-14 17:15:50 +01:00
parent af732c5431
commit 3fbaa4c0b0
19 changed files with 42 additions and 23 deletions
+1 -1
View File
@@ -1121,7 +1121,7 @@ func (o *Object) Size() int64 {
// setMetaData sets the metadata from info
func (o *Object) setMetaData(info *api.Item) (err error) {
if info.Attributes.IsFolder {
return fs.ErrorNotAFile
return fs.ErrorIsDir
}
o.hasMetaData = true
o.size = info.Attributes.StorageInfo.Size