-
Notifications
You must be signed in to change notification settings - Fork 7
added (optional) backup feat for user #50
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: main
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 |
|---|---|---|
|
|
@@ -151,17 +151,29 @@ def change_target_profile(self, profile_name: str): | |
| self.target_data_sources = collect_data_sources(self.target_qgis_ini_file) | ||
| self.target_plugins = collect_plugin_names(self.target_qgis_ini_file) | ||
|
|
||
| def make_backup(self, profile_name: str) -> Optional[str]: | ||
| def make_backup(self, profile_name: str, backup_dir: str) -> Optional[str]: | ||
| """Creates a backup of the specified profile. | ||
|
|
||
| Args: | ||
| profile_name (str): Name of the profile to back up | ||
| backup_dir (str): Directory where backup should be stored | ||
|
|
||
| Returns: | ||
| str: A message if an error occured. | ||
| """ | ||
| ###################################################################### | ||
| backup_path = Path(backup_dir) | ||
|
|
||
| if not backup_path.exists(): | ||
|
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. If it doesn't exists it should be created. What do you think @kannes ? |
||
| QgsMessageLog.logMessage( | ||
| f"invalid backup path: {backup_dir}", | ||
| "Profile Manager", | ||
| level=Qgis.MessageLevel.Info, | ||
| ) | ||
| # return ? | ||
| ###################################################################### | ||
| ts = int(time.time()) | ||
| target_path = self.backup_path / str(ts) | ||
| target_path = backup_path / str(ts) | ||
| source_path = qgis_profiles_path() / profile_name | ||
| QgsMessageLog.logMessage( | ||
| f"Backing up profile {profile_name!r} to {target_path!r}", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,8 +163,14 @@ def _set_qdt_profile_infos(self, qdt_profile_infos: QDTProfileInfos) -> None: | |
| def export_qdt_handler(self) -> None: | ||
| """Export selected profile as QDT profile""" | ||
| profile_path = self.qdt_file_widget.filePath() | ||
| if profile_path: | ||
| backup_path = ( | ||
| self.qdt_backup_file_widget.filePath() | ||
| ) # NEW sets backup_path from Widget | ||
| if profile_path and backup_path: # NEW check for both | ||
|
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. See my remark for the parameter |
||
| source_profile_name = self.qdt_export_profile_cbx.currentText() | ||
| make = self.__profile_manager.make_backup( | ||
| source_profile_name, backup_path | ||
| ) # NEW idk how to name it tbh | ||
| export_profile_for_qdt( | ||
| profile_name=source_profile_name, | ||
| export_path=Path(profile_path), | ||
|
|
||
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.
@snennis The
backup_dirshould be optionnal.make_backupis used outside qdt export and there will be an regression.IMHO we should make it optional and use default value
self.backup_dirif not defined.What do you think @kannes ?