From 232d304c1324d4c7d1cbcf276997dcfc668fc618 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 25 Apr 2023 12:07:56 +0100 Subject: [PATCH] drive: fix trailing slash mis-identificaton of folder as file Before this change, drive would mistakenly identify a folder with a training slash as a file when passed to NewObject. This was picked up by the integration tests --- backend/drive/drive.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 5f1472ccf..625f4a303 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -1512,6 +1512,9 @@ func (f *Fs) newObjectWithExportInfo( // NewObject finds the Object at remote. If it can't be found // it returns the error fs.ErrorObjectNotFound. func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error) { + if strings.HasSuffix(remote, "/") { + return nil, fs.ErrorIsDir + } info, extension, exportName, exportMimeType, isDocument, err := f.getRemoteInfoWithExport(ctx, remote) if err != nil { return nil, err