Features: 1) Introduced AbsoluteFTPStorage class for path customization in FTP storage; 2) Updated dbbackup settings to use AbsoluteFTPStorage for FTP storage configurations.
Fixes: 1) Corrected `DBBACKUP_PATH` default to ensure proper backup directory structure. Extra: 1) Minor cleanup in FTP storage configuration handling.
This commit is contained in:
parent
2cbea05ea7
commit
e373f28358
2 changed files with 14 additions and 3 deletions
11
evibes/ftpstorage.py
Normal file
11
evibes/ftpstorage.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from urllib.parse import urlparse
|
||||
|
||||
from storages.backends.ftp import FTPStorage
|
||||
|
||||
|
||||
class AbsoluteFTPStorage(FTPStorage): # type: ignore
|
||||
def _get_config(self):
|
||||
cfg = super()._get_config()
|
||||
url = urlparse(self.location)
|
||||
cfg["path"] = url.path or cfg["path"]
|
||||
return cfg
|
||||
|
|
@ -13,7 +13,7 @@ if getenv("DBBACKUP_HOST") and getenv("DBBACKUP_USER") and getenv("DBBACKUP_PASS
|
|||
dbbackup_server_type = getenv("DBBACKUP_TYPE", "sftp")
|
||||
project_name = getenv("EVIBES_PROJECT_NAME", "evibes_common").lower().replace(" ", "_")
|
||||
|
||||
raw_path = getenv("DBBACKUP_PATH", f"backups/{project_name}")
|
||||
raw_path = getenv("DBBACKUP_PATH", f"/backups/{project_name}/")
|
||||
cleaned = raw_path.strip("/")
|
||||
remote_dir = f"{cleaned}/"
|
||||
|
||||
|
|
@ -35,13 +35,13 @@ if getenv("DBBACKUP_HOST") and getenv("DBBACKUP_USER") and getenv("DBBACKUP_PASS
|
|||
}
|
||||
|
||||
case "ftp":
|
||||
DBBACKUP_STORAGE = "storages.backends.ftp.FTPStorage"
|
||||
DBBACKUP_STORAGE = "evibes.ftpstorage.AbsoluteFTPStorage"
|
||||
DBBACKUP_STORAGE_OPTIONS = {
|
||||
"location": (
|
||||
f"ftp://{getenv('DBBACKUP_USER')}:"
|
||||
f"{getenv('DBBACKUP_PASS')}@"
|
||||
f"{getenv('DBBACKUP_HOST')}:21/"
|
||||
f"{remote_dir}"
|
||||
f"{raw_path}"
|
||||
),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue