Skip to content

Commit 851e795

Browse files
committed
wip: vfs: use specialized stat interface when available rather than
listing Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
1 parent 213f40e commit 851e795

File tree

9 files changed

+221
-88
lines changed

9 files changed

+221
-88
lines changed

backend/drive/drive.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3798,16 +3798,16 @@ Use the --interactive/-i or --dry-run flag to see what would be moved beforehand
37983798
Usage:
37993799
38003800
rclone backend query drive: query
3801-
3802-
The query syntax is documented at [Google Drive Search query terms and
3801+
3802+
The query syntax is documented at [Google Drive Search query terms and
38033803
operators](https://developers.google.com/drive/api/guides/ref-search-terms).
38043804
38053805
For example:
38063806
38073807
rclone backend query drive: "'0ABc9DEFGHIJKLMNop0QRatUVW3X' in parents and name contains 'foo'"
38083808
38093809
If the query contains literal ' or \ characters, these need to be escaped with
3810-
\ characters. "'" becomes "\'" and "\" becomes "\\\", for example to match a
3810+
\ characters. "'" becomes "\'" and "\" becomes "\\\", for example to match a
38113811
file named "foo ' \.txt":
38123812
38133813
rclone backend query drive: "name = 'foo \' \\\.txt'"

backend/local/local.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,13 @@ func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[str
11231123
}
11241124
}
11251125

1126+
// Stat returns the DirEntry for the given name
1127+
//
1128+
// It should return fs.ErrorNotImplemented if it can't return a DirEntry
1129+
func (f *Fs) Stat(ctx context.Context, dir string, leaf string) (fs.DirEntry, error) {
1130+
return nil, fs.ErrorNotImplemented
1131+
}
1132+
11261133
// ------------------------------------------------------------
11271134

11281135
// Fs returns the parent Fs
@@ -1768,6 +1775,7 @@ var (
17681775
_ fs.OpenWriterAter = &Fs{}
17691776
_ fs.DirSetModTimer = &Fs{}
17701777
_ fs.MkdirMetadataer = &Fs{}
1778+
_ fs.Stater = &Fs{}
17711779
_ fs.Object = &Object{}
17721780
_ fs.Metadataer = &Object{}
17731781
_ fs.SetMetadataer = &Object{}

backend/onedrive/onedrive.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ block download of the file.
356356
357357
In this case you will see a message like this
358358
359-
server reports this file is infected with a virus - use --onedrive-av-override to download anyway: Infected (name of virus): 403 Forbidden:
359+
server reports this file is infected with a virus - use --onedrive-av-override to download anyway: Infected (name of virus): 403 Forbidden:
360360
361361
If you are 100% sure you want to download this file anyway then use
362362
the --onedrive-av-override flag, or av_override = true in the config
@@ -2988,13 +2988,13 @@ var (
29882988
_ fs.ListRer = (*Fs)(nil)
29892989
_ fs.Shutdowner = (*Fs)(nil)
29902990
_ fs.Object = (*Object)(nil)
2991-
_ fs.MimeTyper = &Object{}
2992-
_ fs.IDer = &Object{}
2991+
_ fs.MimeTyper = (*Object)(nil)
2992+
_ fs.IDer = (*Object)(nil)
29932993
_ fs.Metadataer = (*Object)(nil)
29942994
_ fs.Metadataer = (*Directory)(nil)
29952995
_ fs.SetModTimer = (*Directory)(nil)
29962996
_ fs.SetMetadataer = (*Directory)(nil)
2997-
_ fs.MimeTyper = &Directory{}
2997+
_ fs.MimeTyper = (*Directory)(nil)
29982998
_ fs.DirSetModTimer = (*Fs)(nil)
29992999
_ fs.MkdirMetadataer = (*Fs)(nil)
30003000
)

backend/union/union.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,13 @@ func (f *Fs) CleanUp(ctx context.Context) error {
911911
return errs.Err()
912912
}
913913

914+
// Stat returns the DirEntry for the given name
915+
//
916+
// It should return fs.ErrorNotImplemented if it can't return a DirEntry
917+
func (f *Fs) Stat(ctx context.Context, dir string, leaf string) (fs.DirEntry, error) {
918+
return nil, fs.ErrorNotImplemented
919+
}
920+
914921
// NewFs constructs an Fs from the path.
915922
//
916923
// The returned Fs is the actual Fs, referenced by remote in the config
@@ -1093,4 +1100,5 @@ var (
10931100
_ fs.ListRer = (*Fs)(nil)
10941101
_ fs.Shutdowner = (*Fs)(nil)
10951102
_ fs.CleanUpper = (*Fs)(nil)
1103+
_ fs.Stater = (*Fs)(nil)
10961104
)

fs/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ type Fder interface {
218218
Fd(ctx context.Context, flags int) (uintptr, error)
219219
}
220220

221+
// Stater is an optional interface for Directory
222+
type Stater interface {
223+
// Stat returns the DirEntry for the given leaf
224+
//
225+
// It should return fs.ErrorNotImplemented if it can't return a DirEntry
226+
Stat(ctx context.Context, dir string, leaf string) (DirEntry, error)
227+
}
228+
221229
// SetModTimer is an optional interface for Directory.
222230
//
223231
// Object implements this as part of its requires set of interfaces.

0 commit comments

Comments
 (0)