filename handling for archive files.

This commit is contained in:
jonaswinkler
2020-11-30 21:38:21 +01:00
parent 1df64e3129
commit f08d494f1b
7 changed files with 111 additions and 35 deletions

View File

@@ -11,10 +11,13 @@ def create_source_path_directory(source_path):
# TODO: also make this work for archive dir
def delete_empty_directories(directory):
def delete_empty_directories(directory, root):
if not os.path.isdir(directory):
return
# Go up in the directory hierarchy and try to delete all directories
directory = os.path.normpath(directory)
root = os.path.normpath(settings.ORIGINALS_DIR)
root = os.path.normpath(root)
if not directory.startswith(root + os.path.sep):
# don't do anything outside our originals folder.
@@ -102,3 +105,8 @@ def generate_filename(doc):
filename += ".gpg"
return filename
def archive_name_from_filename(filename):
return os.path.splitext(filename)[0] + ".pdf"