mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 07:29:35 +01:00
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
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 != "" {
|
||||
// Escaping the backslash isn't documented but seems to work
|
||||
title = strings.Replace(title, `\`, `\\`, -1)
|
||||
title = strings.Replace(title, `'`, `\'`, -1)
|
||||
searchTitle := strings.Replace(title, `\`, `\\`, -1)
|
||||
searchTitle = strings.Replace(searchTitle, `'`, `\'`, -1)
|
||||
// Convert / to / for search
|
||||
title = strings.Replace(title, "/", "/", -1)
|
||||
query = append(query, fmt.Sprintf("name='%s'", title))
|
||||
searchTitle = strings.Replace(searchTitle, "/", "/", -1)
|
||||
// use contains to work around #1675
|
||||
query = append(query, fmt.Sprintf("name contains '%s'", searchTitle))
|
||||
}
|
||||
if directoriesOnly {
|
||||
query = append(query, fmt.Sprintf("mimeType='%s'", driveFolderType))
|
||||
@ -296,6 +297,10 @@ OUTER:
|
||||
for _, item := range files.Files {
|
||||
// Convert / to / for listing purposes
|
||||
item.Name = strings.Replace(item.Name, "/", "/", -1)
|
||||
// skip items introduced by workaround (#1675)
|
||||
if title != "" && title != item.Name {
|
||||
continue
|
||||
}
|
||||
if fn(item) {
|
||||
found = true
|
||||
break OUTER
|
||||
|
Loading…
Reference in New Issue
Block a user