diff --git a/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php b/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php index 87b1f60da..84ff1576b 100644 --- a/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php +++ b/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php @@ -33,6 +33,19 @@ public function index($id, $pattern) // Escape trailing backslashes, else there would be an error with ilike. $pattern = preg_replace('/\\\\$/', '\\\\\\\\', $pattern); + $files = explode(',', $pattern); + if (count($files) > 1) { + $files = collect($files)->map( + function ($f) { + $filename = trim($f); + return strlen($filename) > 0 ? $filename : null; + } + )->whereNotNull(); + + return $files->chunk(1000)->flatMap(fn ($chunk) + => $volume->files()->whereIn('filename', $chunk)->pluck('id')); + } + return $volume->files() ->where('filename', 'ilike', str_replace('*', '%', $pattern)) ->pluck('id'); diff --git a/resources/views/volumes/clone.blade.php b/resources/views/volumes/clone.blade.php index d21c1aecc..8b6abbcb9 100644 --- a/resources/views/volumes/clone.blade.php +++ b/resources/views/volumes/clone.blade.php @@ -74,7 +74,7 @@ v-on:keydown.enter="loadFilesMatchingPattern"> @endif - Filter by using a pattern that matches specific file names. A pattern may contain the wildcard character * that matches any string of zero or more characters + Filter by using a list of comma-separated file names or a pattern that matches specific file names. A pattern may contain the wildcard character * that matches any string of zero or more characters