fixed an issue with the date-based remote paths

This commit is contained in:
kageru 2018-03-27 12:49:27 +02:00
parent 4f4d20c664
commit 4e258d1a04
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -94,7 +94,10 @@ def ftp_upload(sourcefile, *, mode=None, ext=None) -> tuple:
with Connection(config.sftp_address, username=config.username, password=config.password, port=config.sftp_port,
private_key=config.private_key, private_key_pass=config.private_key_pass) as conn:
full_remote_dir = os.path.join(config.remote_directory, get_date_folder())
if config.preserve_folders_on_remote:
full_remote_dir = os.path.join(config.remote_directory, get_date_folder())
else:
full_remote_dir = config.remote_directory
if not conn.exists(full_remote_dir):
conn.makedirs(full_remote_dir)
conn.chdir(full_remote_dir)
@ -114,7 +117,10 @@ def ftp_upload(sourcefile, *, mode=None, ext=None) -> tuple:
fullpath = os.path.join(get_local_full_path(), filename)
url = config.url_template.format(os.path.join(get_date_folder(), filename))
if config.preserve_folders_on_remote:
url = config.url_template.format(os.path.join(get_date_folder(), filename))
else:
url = config.url_template.format(filename)
notify_user(url, fullpath if mode=='screenshot' else None)
return fullpath, filename