-
Notifications
You must be signed in to change notification settings - Fork 4
Update rollback.py #612
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
base: feat/rollback
Are you sure you want to change the base?
Update rollback.py #612
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,29 @@ | ||
| """Filesystem utilities for temporary backups and rollback mechanisms.""" | ||
|
|
||
| import os | ||
| import shutil | ||
| import signal | ||
| import tempfile | ||
| from pathlib import Path | ||
| from contextlib import chdir, contextmanager | ||
| from contextlib import contextmanager | ||
|
|
||
| from auto_dev.utils import signals | ||
|
|
||
|
|
||
| # https://www.youtube.com/watch?v=0GRLhpMao3I | ||
| # async-signal safe is the strongest concept of reentrancy. | ||
| # async-signal safe implies thread safe. | ||
|
|
||
| # signal.SIGKILL cannot be intercepted | ||
| SIGNALS_TO_BLOCK = (signal.SIGINT, signal.SIGTERM) | ||
|
|
||
|
|
||
| @contextmanager | ||
| def chdir(new_dir): | ||
| """Change the current working directory temporarily.""" | ||
| old_dir = os.getcwd() | ||
| try: | ||
| os.chdir(new_dir) | ||
| yield | ||
| finally: | ||
| os.chdir(old_dir) | ||
|
Comment on lines
+16
to
+24
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has nothing to do with rollback. Now what? ?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. besides this is not the first version of this context manager just to change dirs either. Why would we keep supporting 3.10?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What exactly does the context lib version of chdir that this does not? I don't really understand why this specific function is so important?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why wouldn't we support 3.10 if all it requires is not using this chdir thing?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well there are other limitations, such as |
||
|
|
||
|
|
||
| def _restore_from_backup(directory: Path, backup: Path): | ||
| for item in directory.rglob("*"): | ||
| backup_item = backup / item.relative_to(directory) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprised the comments passed linters haha