mirror of
https://github.com/borgbase/vorta
synced 2025-01-02 21:25:48 +00:00
Cleanup temp files. By @marco44 (#1384)
This commit is contained in:
parent
8a94457b8d
commit
94e76644c4
3 changed files with 8 additions and 2 deletions
|
@ -104,6 +104,7 @@ def __init__(self, cmd, params, site="default"):
|
|||
self.cwd = params.get('cwd', None)
|
||||
self.params = params
|
||||
self.process = None
|
||||
self.cleanup_files = params.get('cleanup_files', [])
|
||||
|
||||
def repo_id(self):
|
||||
return self.site_id
|
||||
|
@ -182,6 +183,7 @@ def prepare(cls, profile):
|
|||
ret['profile_id'] = profile.id
|
||||
|
||||
ret['ok'] = True
|
||||
ret['cleanup_files'] = []
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -299,6 +301,8 @@ def read_async(fd):
|
|||
self.process_result(result)
|
||||
|
||||
self.finished_event(result)
|
||||
for tmpfile in self.cleanup_files:
|
||||
tmpfile.close()
|
||||
|
||||
def process_result(self, result):
|
||||
pass
|
||||
|
|
|
@ -145,10 +145,11 @@ def prepare(cls, profile):
|
|||
exclude_dirs.append(expanded_directory)
|
||||
|
||||
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.flush()
|
||||
cmd.extend(['--exclude-from', pattern_file.name])
|
||||
ret['cleanup_files'].append(pattern_file)
|
||||
|
||||
if profile.exclude_if_present is not None:
|
||||
for f in profile.exclude_if_present.split('\n'):
|
||||
|
|
|
@ -35,7 +35,7 @@ def prepare(cls, profile, archive_name, model: ExtractTree, destination_folder):
|
|||
# dialog.
|
||||
# Unselected (and excluded) parent folders will be restored by borg
|
||||
# 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")
|
||||
|
||||
indexes = [QModelIndex()]
|
||||
|
@ -54,6 +54,7 @@ def prepare(cls, profile, archive_name, model: ExtractTree, destination_folder):
|
|||
pattern_file.flush()
|
||||
pattern_file.close() # wont delete temp file
|
||||
cmd.extend(['--patterns-from', pattern_file.name])
|
||||
ret['cleanup_files'].append(pattern_file)
|
||||
|
||||
ret['ok'] = True
|
||||
ret['cmd'] = cmd
|
||||
|
|
Loading…
Reference in a new issue