From a59211f2951530b803d34f9aed3505fcef361126 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 11 Jul 2015 17:22:12 +0200 Subject: [PATCH] use borg-tmp as prefix for temporary files / directories also: remove some unused temp dir. code --- borg/archive.py | 6 ------ borg/cache.py | 2 +- borg/fuse.py | 2 +- borg/remote.py | 2 +- borg/xattr.py | 2 +- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/borg/archive.py b/borg/archive.py index 83ac6aecb..bcaf49830 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -2,8 +2,6 @@ from datetime import datetime from getpass import getuser from itertools import groupby import errno -import shutil -import tempfile from .key import key_factory from .remote import cache_if_remote import msgpack @@ -609,10 +607,6 @@ class ArchiveChecker: def __init__(self): self.error_found = False self.possibly_superseded = set() - self.tmpdir = tempfile.mkdtemp() - - def __del__(self): - shutil.rmtree(self.tmpdir) def check(self, repository, repair=False, last=None): self.report_progress('Starting archive consistency check...') diff --git a/borg/cache.py b/borg/cache.py index 110f088d9..5e3039161 100644 --- a/borg/cache.py +++ b/borg/cache.py @@ -313,7 +313,7 @@ class Cache: self.begin_txn() print('Synchronizing chunks cache...') # XXX we have to do stuff on disk due to lacking ChunkIndex api - with tempfile.TemporaryDirectory() as tmp_dir: + with tempfile.TemporaryDirectory(prefix='borg-tmp') as tmp_dir: repository = cache_if_remote(self.repository) out_archive = open_out_archive() in_archive = open_in_archive() diff --git a/borg/fuse.py b/borg/fuse.py index eb4b46ffd..ab28d3b3e 100644 --- a/borg/fuse.py +++ b/borg/fuse.py @@ -17,7 +17,7 @@ have_fuse_mtime_ns = hasattr(llfuse.EntryAttributes, 'st_mtime_ns') class ItemCache: def __init__(self): - self.fd = tempfile.TemporaryFile() + self.fd = tempfile.TemporaryFile(prefix='borg-tmp') self.offset = 1000000 def add(self, item): diff --git a/borg/remote.py b/borg/remote.py index 81d4ace05..93e178f79 100644 --- a/borg/remote.py +++ b/borg/remote.py @@ -305,7 +305,7 @@ class RepositoryCache: self.cleanup() def initialize(self): - self.tmppath = tempfile.mkdtemp() + self.tmppath = tempfile.mkdtemp(prefix='borg-tmp') self.index = NSIndex() self.data_fd = open(os.path.join(self.tmppath, 'data'), 'a+b') diff --git a/borg/xattr.py b/borg/xattr.py index 2201e4b48..ded6d752d 100644 --- a/borg/xattr.py +++ b/borg/xattr.py @@ -11,7 +11,7 @@ from ctypes.util import find_library def is_enabled(path=None): """Determine if xattr is enabled on the filesystem """ - with tempfile.NamedTemporaryFile(dir=path) as fd: + with tempfile.NamedTemporaryFile(dir=path, prefix='borg-tmp') as fd: try: setxattr(fd.fileno(), 'user.name', b'value') except OSError: