Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions ietf/submit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,20 +671,16 @@ def move_files_to_repository(submission):
raise ValueError("Intended to move '%s' to '%s', but found source and destination missing.")


def remove_staging_files(name, rev, exts=None):
"""Remove staging files corresponding to a submission

exts is a list of extensions to be removed. If None, defaults to settings.IDSUBMIT_FILE_TYPES.
"""
if exts is None:
exts = [f'.{ext}' for ext in settings.IDSUBMIT_FILE_TYPES]
def remove_staging_files(name, rev):
"""Remove staging files corresponding to a submission"""
basename = pathlib.Path(settings.IDSUBMIT_STAGING_PATH) / f'{name}-{rev}'
exts = [f'.{ext}' for ext in settings.IDSUBMIT_FILE_TYPES]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting lucky and will only work as long as the set of generated filetypes is a subset of the submitable file types.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to just remove anything with the given stem?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not certain of the history, but I think IDSUBMIT_FILE_TYPES is essentially "extensions that might be associated with a submission" at this point. We use it in a couple places where we move files around. (See rename_submission_files and move_files_to_repository, at least.)

I'm inclined to keep it this way and fix it all when we refactor submission artifact handling.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There'll be an issue to resolve when we're holding both xml2rfc and rfc2html ".html" files.

for ext in exts:
basename.with_suffix(ext).unlink(missing_ok=True)


def remove_submission_files(submission):
remove_staging_files(submission.name, submission.rev, submission.file_types.split(','))
remove_staging_files(submission.name, submission.rev)


def approvable_submissions_for_user(user):
Expand Down