Skip to content

Commit

Permalink
Merge pull request #1072 from biigle/patch-1
Browse files Browse the repository at this point in the history
Implement more efficient volume URL check
  • Loading branch information
mzur authored Feb 5, 2025
2 parents a53c55e + faceeaf commit b57db9c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/Rules/VolumeUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,16 @@ protected function passesDiskUrl($value)
return false;
}

if (empty($disk->files($url[1])) && empty($disk->directories($url[1]))) {
// Access the adapter directly to check for contents without loading the full
// file/directory listing.
$iterable = $disk->getAdapter()->listContents($url[1], false);
$hasContent = false;
foreach ($iterable as $item) {
$hasContent = true;
break;
}

if (!$hasContent) {
$this->message = "Unable to access '{$url[1]}'. Does it exist and you have access permissions?";

return false;
Expand Down

0 comments on commit b57db9c

Please sign in to comment.