mirror of
https://github.com/alexta69/metube.git
synced 2026-09-21 21:45:04 +00:00
fix: strip trailing slashes from the download directories
get_custom_dirs() builds the folder dropdown by removing the base path as a prefix from every subdirectory it finds. The base directory's own path does not carry a trailing slash, so with DOWNLOAD_DIR=/downloads/ the base failed to match itself and fell through to the leading-slash trim, leaking 'downloads' into the dropdown as a bogus folder option. Selecting it would have downloaded into /downloads/downloads. Normalised in Config alongside URL_PREFIX, after the '%%' indirection so AUDIO_DOWNLOAD_DIR is resolved first. '/' and '///' still resolve to '/' rather than the empty string. Found while trying to reproduce #542, which does not reproduce on current code -- both directory listings populate correctly with a distinct AUDIO_DOWNLOAD_DIR. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+11
@@ -116,6 +116,17 @@ class Config:
|
||||
if not self.URL_PREFIX.endswith('/'):
|
||||
self.URL_PREFIX += '/'
|
||||
|
||||
# Strip trailing slashes from the download directories. get_custom_dirs()
|
||||
# builds the folder dropdown by removing the base path as a prefix from
|
||||
# each subdirectory, and the base directory's own path does not carry the
|
||||
# trailing slash — so 'DOWNLOAD_DIR=/downloads/' failed to match itself
|
||||
# and leaked 'downloads' into the dropdown as a bogus folder option.
|
||||
# Runs after the '%%' indirection above so AUDIO_DOWNLOAD_DIR is resolved.
|
||||
for attr in ('DOWNLOAD_DIR', 'AUDIO_DOWNLOAD_DIR', 'TEMP_DIR', 'STATE_DIR'):
|
||||
val = getattr(self, attr)
|
||||
if isinstance(val, str) and len(val) > 1 and val.endswith('/'):
|
||||
setattr(self, attr, val.rstrip('/') or '/')
|
||||
|
||||
# A blank PUBLIC_HOST_AUDIO_URL (e.g. set empty in a compose file) bypasses the
|
||||
# default via os.environ.get, which would leave audio links root-relative and 404.
|
||||
# Fall back to the 'audio_download/' route that serves AUDIO_DOWNLOAD_DIR. When
|
||||
|
||||
Reference in New Issue
Block a user