-
Notifications
You must be signed in to change notification settings - Fork 21
ENT-14056: Moved cache/config-files from .cfengine to .cache/.config #181
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: master
Are you sure you want to change the base?
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -339,3 +339,46 @@ def has_unescaped_character(string, char): | |||||
| return True | ||||||
| previous = current | ||||||
| return False | ||||||
|
|
||||||
|
|
||||||
| def migrate_config_paths(): | ||||||
| override_dir = os.getenv("CF_REMOTE_DIR") | ||||||
| # Set manually by user, assume they want to keep it like that | ||||||
| if override_dir: | ||||||
| return | ||||||
|
|
||||||
| old_dir = os.path.expanduser("~/.cfengine/cf-remote/") | ||||||
| conf_dir = os.path.expanduser("~/.config/cfengine/cf-remote/") | ||||||
| cache_dir = os.path.expanduser("~/.cache/cfengine/cf-remote/") | ||||||
| if os.path.exists(conf_dir) and os.path.exists(cache_dir): | ||||||
| return # Migration has already occured | ||||||
| if not os.path.exists(os.path.dirname(old_dir)): | ||||||
| return # nothing to migrate | ||||||
| shutil.copytree( | ||||||
| old_dir, | ||||||
| conf_dir, | ||||||
| dirs_exist_ok=True, | ||||||
| ignore=shutil.ignore_patterns("json", "packages"), | ||||||
| ) | ||||||
| print("config-files has been moved to '%s'" % conf_dir) | ||||||
|
Member
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.
Suggested change
|
||||||
|
|
||||||
| shutil.copytree( | ||||||
| os.path.join(old_dir, "json"), | ||||||
| os.path.join(cache_dir, "json"), | ||||||
| dirs_exist_ok=True, | ||||||
| ) | ||||||
| shutil.copytree( | ||||||
| os.path.join(old_dir, "packages"), | ||||||
| os.path.join(cache_dir, "packages"), | ||||||
| dirs_exist_ok=True, | ||||||
| ) | ||||||
| print("cache-files has been moved to '%s'" % cache_dir) | ||||||
|
Member
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.
Suggested change
|
||||||
|
|
||||||
| choice = input("Remove directory %s ? [y/N]" % old_dir).strip().lower() or "n" | ||||||
| if choice in "yes": | ||||||
| shutil.rmtree(old_dir) | ||||||
| print("%s has been removed" % old_dir) | ||||||
| return | ||||||
| if choice in "no": | ||||||
| return | ||||||
| print("Unknown input.") | ||||||
|
Comment on lines
+377
to
+384
Member
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. We can't prompt for input like this. cf-remote could be running in a script or similar. I think this migration should be safe to run without prompts, if the copies are successful, the old dir should be removed to avoid confusion / duplication. |
||||||
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.
It's debatable, but I think I would run the migration for the default paths even if a specific dir is specified. If they have something in the default location, they probably want that moved in case the old location will stop working in the future, for example.