It turn out Dropbox is returning an error when listing files in a directory that doesn't exists.
Flysystem follows a Files First approach, and testing out using other drivers results in an empty array:
>>> Storage::disk('local')->allFiles('directory_not_found')
=> []
>>> Storage::disk('dropbox')->allFiles('directory_not_found')
Spatie\Dropbox\Exceptions\BadRequest with message 'path/not_found/'
This PR wraps dropbox call in a try-catch returning an empty array if BadRequest is thrown.
Reading dropbox documentation the only available error using this command is path LookupError, so there're only two possible errors here: not_found, not_folder.
I checked the behavior of the local driver when "listing files" given an existing file as path instead of a folder, it returns and empty array. So I assume catching all dropbox errors is consistent with Flysystem behavior.
I was using Laravel Backup to save my backup into a dropbox account. When calling
backup:list
before running any backup an exception was thrown:It turn out Dropbox is returning an error when listing files in a directory that doesn't exists.
Flysystem follows a Files First approach, and testing out using other drivers results in an empty array:
This PR wraps dropbox call in a try-catch returning an empty array if
BadRequest
is thrown.Reading dropbox documentation the only available error using this command is path LookupError, so there're only two possible errors here:
not_found
,not_folder
.I checked the behavior of the local driver when "listing files" given an existing file as path instead of a folder, it returns and empty array. So I assume catching all dropbox errors is consistent with Flysystem behavior.