Using specific errors to refuse file refresh.

This commit is contained in:
Roland 2023-08-22 12:48:21 -06:00
parent 831bfb98a2
commit 8ba5b63221
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -431,9 +431,11 @@ async def refresh_discover_paths(paths: List[pathlib.Path], idempotency: datetim
Will refuse to refresh when the media directory is empty."""
try:
next(get_media_directory().iterdir())
except:
except StopIteration:
# We don't want to delete a bunch of files which would exist if the drive was mounted.
raise UnknownDirectory(f'Refusing to refresh because media directory is empty or does not exist.')
except FileNotFoundError:
raise UnknownDirectory(f'Refusing to refresh because media directory is empty or does not exist.')
if not paths:
raise ValueError('Must provide some paths to refresh.')