1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-02-22 06:10:35 +00:00

Bugfix in borg-runner.

This commit is contained in:
Manu 2018-10-29 01:15:09 +08:00
parent 4c375f9547
commit d4a5518606
3 changed files with 20 additions and 19 deletions

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>287</height>
<width>555</width>
<height>257</height>
</rect>
</property>
<property name="windowTitle">
@ -23,16 +23,16 @@
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="leftMargin">
<number>20</number>
<number>5</number>
</property>
<property name="topMargin">
<number>20</number>
<number>5</number>
</property>
<property name="rightMargin">
<number>20</number>
<number>5</number>
</property>
<property name="bottomMargin">
<number>20</number>
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
@ -101,7 +101,7 @@
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>

View file

@ -7,7 +7,6 @@
from datetime import datetime as dt
from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication
import subprocess
from subprocess import Popen, PIPE
from .models import SourceDirModel, BackupProfileModel
@ -42,7 +41,6 @@ def __init__(self, parent, cmd, params):
def run(self):
with Popen(self.cmd, stdout=PIPE, stderr=PIPE, bufsize=1, universal_newlines=True, env=self.env) as p:
for line in p.stderr:
print(line)
try:
parsed = json.loads(line)
if parsed['type'] == 'log_message':
@ -70,13 +68,18 @@ def create_thread_factory(cls):
"""`borg create` is called from different places and need preparation.
Centralize it here and return a thread to the caller.
"""
ret = {
'ok': False,
}
profile = BackupProfileModel.get(id=1)
app = QApplication.instance()
n_backup_folders = SourceDirModel.select().count()
ret = {
'ok': False,
}
params = {'password': profile.repo.password}
if app.thread and app.thread.isRunning():
ret['message'] = 'Backup is already in progress.'
return ret
@ -105,6 +108,7 @@ def create_thread_factory(cls):
pattern_file.write('\n'.join(exclude_dirs))
pattern_file.flush()
cmd.extend(['--exclude-from', pattern_file.name])
params['pattern_file'] = pattern_file
if profile.exclude_if_present is not None:
for f in profile.exclude_if_present.split('\n'):
@ -117,9 +121,6 @@ def create_thread_factory(cls):
for f in SourceDirModel.select():
cmd.append(f.dir)
params = {'password': profile.repo.password,
'pattern_file': pattern_file}
app.thread = cls(app, cmd, params)
ret['message'] = 'Starting Backup.'
ret['ok'] = True

View file

@ -76,7 +76,7 @@ def cancel_create_action(self):
self.createStartBtn.repaint()
self.set_status(progress_max=100)
except:
print('no thread')
pass
def create_get_result(self, result):
self.createStartBtn.setEnabled(True)
@ -86,9 +86,9 @@ def create_get_result(self, result):
new_snapshot, created = SnapshotModel.get_or_create(
snapshot_id=result['data']['archive']['id'],
defaults={
'name':result['data']['archive']['name'],
'time':parser.parse(result['data']['archive']['start']),
'repo':self.profile.repo
'name': result['data']['archive']['name'],
'time': parser.parse(result['data']['archive']['start']),
'repo': self.profile.repo
}
)
new_snapshot.save()