def process_result(self, result): if result['returncode'] == 0: remote_archives = result['data'].get('archives', []) # get info stored during BorgThread.prepare() # repo_id = self.params['repo_id'] repo_id = result['params']['repo_id'] # Update remote archives. for remote_archive in remote_archives: archive = ArchiveModel.get_or_none( snapshot_id=remote_archive['id'], repo=repo_id) archive.name = remote_archive['name'] # incase name changed # archive.time = parser.parse(remote_archive['time']) archive.duration = remote_archive['duration'] archive.size = remote_archive['stats']['deduplicated_size'] archive.save() if 'cache' in result['data']: stats = result['data']['cache']['stats'] repo = RepoModel.get(id=result['params']['repo_id']) repo.total_size = stats['total_size'] repo.unique_csize = stats['unique_csize'] repo.unique_size = stats['unique_size'] repo.total_unique_chunks = stats['total_unique_chunks'] repo.save()
def rename_action(self): profile = self.profile() params = BorgRenameThread.prepare(profile) if not params['ok']: self._set_status(params['message']) return archive_name = self.selected_archive_name() if archive_name is not None: new_name, finished = QInputDialog.getText( self, self.tr("Change name"), self.tr("New archive name:"), text=archive_name) if not finished: return if not new_name: self._set_status(self.tr('Archive name cannot be blank.')) return new_name_exists = ArchiveModel.get_or_none(name=new_name, repo=profile.repo) if new_name_exists is not None: self._set_status( self.tr('An archive with this name already exists.')) return params['cmd'][-1] += f'::{archive_name}' params['cmd'].append(new_name) thread = BorgRenameThread(params['cmd'], params, parent=self) thread.updated.connect(self._set_status) thread.result.connect(self.rename_result) self._toggle_all_buttons(False) thread.start() else: self._set_status(self.tr("No archive selected"))