mirror of
https://github.com/borgbase/vorta
synced 2024-12-22 07:43:09 +00:00
Move rename logic for arguments into BorgRenameJob
.
* src/vorta/borg/rename.py * src/vorta/views/archive_tab.py
This commit is contained in:
parent
f9d1260316
commit
ba5c7c5511
2 changed files with 15 additions and 15 deletions
|
@ -8,7 +8,7 @@ def log_event(self, msg):
|
|||
self.app.backup_log_event.emit(msg)
|
||||
|
||||
@classmethod
|
||||
def prepare(cls, profile):
|
||||
def prepare(cls, profile, old_archive_name, new_archive_name):
|
||||
ret = super().prepare(profile)
|
||||
if not ret['ok']:
|
||||
return ret
|
||||
|
@ -17,10 +17,13 @@ def prepare(cls, profile):
|
|||
|
||||
cmd = ['borg', 'rename', '--info', '--log-json']
|
||||
if borg_compat.check('V2'):
|
||||
cmd.extend(["-r", profile.repo.url])
|
||||
cmd.extend(["-r", profile.repo.url, old_archive_name, new_archive_name])
|
||||
else:
|
||||
cmd.append(f'{profile.repo.url}')
|
||||
cmd.extend([f'{profile.repo.url}::{old_archive_name}', new_archive_name])
|
||||
|
||||
ret['old_archive_name'] = old_archive_name
|
||||
ret['new_archive_name'] = new_archive_name
|
||||
ret['repo_url'] = profile.repo.url
|
||||
ret['ok'] = True
|
||||
ret['cmd'] = cmd
|
||||
|
||||
|
@ -28,9 +31,7 @@ def prepare(cls, profile):
|
|||
|
||||
def process_result(self, result):
|
||||
if result['returncode'] == 0:
|
||||
repo_url, old_name = result['cmd'][-2].split('::')
|
||||
new_name = result['cmd'][-1]
|
||||
repo = RepoModel.get(url=repo_url)
|
||||
renamed_archive = ArchiveModel.get(name=old_name, repo=repo)
|
||||
renamed_archive.name = new_name
|
||||
repo = RepoModel.get(url=result['params']['repo_url'])
|
||||
renamed_archive = ArchiveModel.get(name=result['params']['old_archive_name'], repo=repo)
|
||||
renamed_archive.name = result['params']['new_archive_name']
|
||||
renamed_archive.save()
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
from vorta.borg.rename import BorgRenameJob
|
||||
from vorta.borg.umount import BorgUmountJob
|
||||
from vorta.store.models import ArchiveModel, BackupProfileMixin
|
||||
from vorta.utils import choose_file_dialog, format_archive_name, get_asset, get_mount_points, pretty_bytes
|
||||
from vorta.utils import choose_file_dialog, format_archive_name, get_asset, get_mount_points, pretty_bytes, borg_compat
|
||||
from vorta.views import diff_result, extract_dialog
|
||||
from vorta.views.diff_result import DiffResultDialog, DiffTree
|
||||
from vorta.views.extract_dialog import ExtractDialog, ExtractTree
|
||||
|
@ -907,10 +907,7 @@ def show_diff_result(self, archive_newer, archive_older, model):
|
|||
|
||||
def rename_action(self):
|
||||
profile = self.profile()
|
||||
params = BorgRenameJob.prepare(profile)
|
||||
if not params['ok']:
|
||||
self._set_status(params['message'])
|
||||
return
|
||||
|
||||
|
||||
archive_name = self.selected_archive_name()
|
||||
if archive_name is not None:
|
||||
|
@ -933,8 +930,10 @@ def rename_action(self):
|
|||
self._set_status(self.tr('An archive with this name already exists.'))
|
||||
return
|
||||
|
||||
params['cmd'][-1] += f'::{archive_name}'
|
||||
params['cmd'].append(new_name)
|
||||
params = BorgRenameJob.prepare(profile, archive_name, new_name)
|
||||
if not params['ok']:
|
||||
self._set_status(params['message'])
|
||||
|
||||
job = BorgRenameJob(params['cmd'], params, self.profile().repo.id)
|
||||
job.updated.connect(self._set_status)
|
||||
job.result.connect(self.rename_result)
|
||||
|
|
Loading…
Reference in a new issue