Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission.create_files: Set remove_old default to False #193

Merged
merged 1 commit into from
Jan 13, 2022

Conversation

AndreasAlbert
Copy link
Collaborator

Closes #192

@clelange
Copy link
Collaborator

Thanks for the quick fix! I think we should take this a bit further and actually prohibit having the directory, in which the python script resides, be the same as the output directory (and the script directory must also not be a subdirectory of the output directory). This should protect us from accidental file deletion. What do you think?

@AndreasAlbert
Copy link
Collaborator Author

I support making this overall more robust. However, I think that tacking on individual checks for specific edge cases might not be the best approach as we might still miss something. How about instead, we generally force the user to use a previously nonexistant directory the first time they execute create_files. That would require us to preserve between runs the knowledge of whether or not a given directory was originally created by hepdata_lib. We could easily accomplish this by depositing an empty signifier file (e.g. $DIRECTORY/.created_by_hepdata_lib) in the desired directory. Each time it is run, create_files would check whether the output directory exists already and whether the signifier file exists. If the directory does not yet exist, we proceed as normal with creating the directory as well as the signifier file. If the directory exists, but the file does not, we exit and give the user a warning telling them that they should use a dedicated empty directory in order to avoid trouble.

Right this moment, though, we have code published on pypi that can accidentally wipe user files with default settings. Therefore, let's please merge this hot fix and mint a new version. That buys us a little time to think through how to really fix this once and for all.

@clelange clelange merged commit 312c8b2 into master Jan 13, 2022
@clelange clelange deleted the 2022-01-12_fix_deletion_default branch January 13, 2022 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

submission.create_files() fails and wipes the directory clean
2 participants