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:
@@ -337,8 +337,12 @@ func (f *Fs) readMetaDataForIDPath(ctx context.Context, id, path string, directo
|
||||
if directoriesOnly && item.Type != api.ItemTypeFolder {
|
||||
return nil, fs.ErrorIsFile
|
||||
}
|
||||
if filesOnly && item.Type != api.ItemTypeFile {
|
||||
return nil, fs.ErrorNotAFile
|
||||
if filesOnly {
|
||||
if item.Type == api.ItemTypeFolder {
|
||||
return nil, fs.ErrorIsDir
|
||||
} else if item.Type != api.ItemTypeFile {
|
||||
return nil, fs.ErrorNotAFile
|
||||
}
|
||||
}
|
||||
return &item, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user