1
mirror of https://github.com/rclone/rclone synced 2024-09-18 15:28:08 +02:00

mount: Make include and exclude filters apply to mount - fixes #1060

This commit is contained in:
Nick Craig-Wood 2017-02-15 23:26:40 +00:00
parent b52c80e85c
commit dac4bb22d3
3 changed files with 33 additions and 22 deletions

View File

@ -78,7 +78,7 @@ func (d *Dir) readDir() error {
} }
fs.Debugf(d.path, "Re-reading directory (%v old)", age) fs.Debugf(d.path, "Re-reading directory (%v old)", age)
} }
objs, dirs, err := fs.NewLister().SetLevel(1).Start(d.f, d.path).GetAll() entries, err := fs.ListDirSorted(d.f, false, d.path)
if err == fs.ErrorDirNotFound { if err == fs.ErrorDirNotFound {
// We treat directory not found as empty because we // We treat directory not found as empty because we
// create directories on the fly // create directories on the fly
@ -93,26 +93,34 @@ func (d *Dir) readDir() error {
oldItems := d.items oldItems := d.items
// Cache the items by name // Cache the items by name
d.items = make(map[string]*DirEntry, len(objs)+len(dirs)) d.items = make(map[string]*DirEntry, len(entries))
for _, obj := range objs { for _, entry := range entries {
name := path.Base(obj.Remote()) switch item := entry.(type) {
d.items[name] = &DirEntry{ case fs.Object:
o: obj, obj := item
node: nil, name := path.Base(obj.Remote())
} d.items[name] = &DirEntry{
} o: obj,
for _, dir := range dirs { node: nil,
name := path.Base(dir.Remote())
// Use old dir value if it exists
if oldItem, ok := oldItems[name]; ok {
if _, ok := oldItem.o.(*fs.Dir); ok {
d.items[name] = oldItem
continue
} }
} case *fs.Dir:
d.items[name] = &DirEntry{ dir := item
o: dir, name := path.Base(dir.Remote())
node: nil, // Use old dir value if it exists
if oldItem, ok := oldItems[name]; ok {
if _, ok := oldItem.o.(*fs.Dir); ok {
d.items[name] = oldItem
continue
}
}
d.items[name] = &DirEntry{
o: dir,
node: nil,
}
default:
err = errors.Errorf("unknown type %T", item)
fs.Errorf(d.path, "readDir error: %v", err)
return err
} }
} }
d.read = when d.read = when

View File

@ -114,6 +114,11 @@ can't use retries in the same way without making local copies of the
uploads. This might happen in the future, but for the moment rclone uploads. This might happen in the future, but for the moment rclone
mount won't do that, so will be less reliable than the rclone command. mount won't do that, so will be less reliable than the rclone command.
### Filters ###
Note that all the rclone filters can be used to select a subset of the
files to be visible in the mount.
### Bugs ### ### Bugs ###
* All the remotes should work for read, but some may not for write * All the remotes should work for read, but some may not for write

View File

@ -530,8 +530,6 @@ func (ds DirEntries) Less(i, j int) bool {
return ds[i].Remote() < ds[j].Remote() return ds[i].Remote() < ds[j].Remote()
} }
// FIXME can use this in Mount
// ListDirSorted reads Object and *Dir into entries for the given Fs. // ListDirSorted reads Object and *Dir into entries for the given Fs.
// //
// dir is the start directory, "" for root // dir is the start directory, "" for root