mirror of https://github.com/borgbase/vorta
Cleanup temp files. By @marco44 (#1384)
This commit is contained in:
parent
8a94457b8d
commit
94e76644c4
|
@ -104,6 +104,7 @@ class BorgJob(JobInterface, BackupProfileMixin):
|
||||||
self.cwd = params.get('cwd', None)
|
self.cwd = params.get('cwd', None)
|
||||||
self.params = params
|
self.params = params
|
||||||
self.process = None
|
self.process = None
|
||||||
|
self.cleanup_files = params.get('cleanup_files', [])
|
||||||
|
|
||||||
def repo_id(self):
|
def repo_id(self):
|
||||||
return self.site_id
|
return self.site_id
|
||||||
|
@ -182,6 +183,7 @@ class BorgJob(JobInterface, BackupProfileMixin):
|
||||||
ret['profile_id'] = profile.id
|
ret['profile_id'] = profile.id
|
||||||
|
|
||||||
ret['ok'] = True
|
ret['ok'] = True
|
||||||
|
ret['cleanup_files'] = []
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -299,6 +301,8 @@ class BorgJob(JobInterface, BackupProfileMixin):
|
||||||
self.process_result(result)
|
self.process_result(result)
|
||||||
|
|
||||||
self.finished_event(result)
|
self.finished_event(result)
|
||||||
|
for tmpfile in self.cleanup_files:
|
||||||
|
tmpfile.close()
|
||||||
|
|
||||||
def process_result(self, result):
|
def process_result(self, result):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -145,10 +145,11 @@ class BorgCreateJob(BorgJob):
|
||||||
exclude_dirs.append(expanded_directory)
|
exclude_dirs.append(expanded_directory)
|
||||||
|
|
||||||
if exclude_dirs:
|
if exclude_dirs:
|
||||||
pattern_file = tempfile.NamedTemporaryFile('w', delete=False)
|
pattern_file = tempfile.NamedTemporaryFile('w', delete=True)
|
||||||
pattern_file.write('\n'.join(exclude_dirs))
|
pattern_file.write('\n'.join(exclude_dirs))
|
||||||
pattern_file.flush()
|
pattern_file.flush()
|
||||||
cmd.extend(['--exclude-from', pattern_file.name])
|
cmd.extend(['--exclude-from', pattern_file.name])
|
||||||
|
ret['cleanup_files'].append(pattern_file)
|
||||||
|
|
||||||
if profile.exclude_if_present is not None:
|
if profile.exclude_if_present is not None:
|
||||||
for f in profile.exclude_if_present.split('\n'):
|
for f in profile.exclude_if_present.split('\n'):
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BorgExtractJob(BorgJob):
|
||||||
# dialog.
|
# dialog.
|
||||||
# Unselected (and excluded) parent folders will be restored by borg
|
# Unselected (and excluded) parent folders will be restored by borg
|
||||||
# but without the metadata stored in the archive.
|
# but without the metadata stored in the archive.
|
||||||
pattern_file = tempfile.NamedTemporaryFile('w', delete=False)
|
pattern_file = tempfile.NamedTemporaryFile('w', delete=True)
|
||||||
pattern_file.write("P fm\n")
|
pattern_file.write("P fm\n")
|
||||||
|
|
||||||
indexes = [QModelIndex()]
|
indexes = [QModelIndex()]
|
||||||
|
@ -54,6 +54,7 @@ class BorgExtractJob(BorgJob):
|
||||||
pattern_file.flush()
|
pattern_file.flush()
|
||||||
pattern_file.close() # wont delete temp file
|
pattern_file.close() # wont delete temp file
|
||||||
cmd.extend(['--patterns-from', pattern_file.name])
|
cmd.extend(['--patterns-from', pattern_file.name])
|
||||||
|
ret['cleanup_files'].append(pattern_file)
|
||||||
|
|
||||||
ret['ok'] = True
|
ret['ok'] = True
|
||||||
ret['cmd'] = cmd
|
ret['cmd'] = cmd
|
||||||
|
|
Loading…
Reference in New Issue