forked from TrueCloudLab/rclone
drive: use contains for name matching in list
Use contains for name matching in list to work around #1675.
This commit is contained in:
parent
07f20dd1fd
commit
f622017539
2 changed files with 9 additions and 4 deletions
BIN
backend/drive/debug.test
Executable file
BIN
backend/drive/debug.test
Executable file
Binary file not shown.
|
@ -248,11 +248,12 @@ func (f *Fs) list(dirID string, title string, directoriesOnly bool, filesOnly bo
|
||||||
}
|
}
|
||||||
if title != "" {
|
if title != "" {
|
||||||
// Escaping the backslash isn't documented but seems to work
|
// Escaping the backslash isn't documented but seems to work
|
||||||
title = strings.Replace(title, `\`, `\\`, -1)
|
searchTitle := strings.Replace(title, `\`, `\\`, -1)
|
||||||
title = strings.Replace(title, `'`, `\'`, -1)
|
searchTitle = strings.Replace(searchTitle, `'`, `\'`, -1)
|
||||||
// Convert / to / for search
|
// Convert / to / for search
|
||||||
title = strings.Replace(title, "/", "/", -1)
|
searchTitle = strings.Replace(searchTitle, "/", "/", -1)
|
||||||
query = append(query, fmt.Sprintf("name='%s'", title))
|
// use contains to work around #1675
|
||||||
|
query = append(query, fmt.Sprintf("name contains '%s'", searchTitle))
|
||||||
}
|
}
|
||||||
if directoriesOnly {
|
if directoriesOnly {
|
||||||
query = append(query, fmt.Sprintf("mimeType='%s'", driveFolderType))
|
query = append(query, fmt.Sprintf("mimeType='%s'", driveFolderType))
|
||||||
|
@ -296,6 +297,10 @@ OUTER:
|
||||||
for _, item := range files.Files {
|
for _, item := range files.Files {
|
||||||
// Convert / to / for listing purposes
|
// Convert / to / for listing purposes
|
||||||
item.Name = strings.Replace(item.Name, "/", "/", -1)
|
item.Name = strings.Replace(item.Name, "/", "/", -1)
|
||||||
|
// skip items introduced by workaround (#1675)
|
||||||
|
if title != "" && title != item.Name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if fn(item) {
|
if fn(item) {
|
||||||
found = true
|
found = true
|
||||||
break OUTER
|
break OUTER
|
||||||
|
|
Loading…
Reference in a new issue