2
0
Эх сурвалжийг харах

use borg-tmp as prefix for temporary files / directories

also: remove some unused temp dir. code
Thomas Waldmann 10 жил өмнө
parent
commit
a59211f295
5 өөрчлөгдсөн 4 нэмэгдсэн , 10 устгасан
  1. 0 6
      borg/archive.py
  2. 1 1
      borg/cache.py
  3. 1 1
      borg/fuse.py
  4. 1 1
      borg/remote.py
  5. 1 1
      borg/xattr.py

+ 0 - 6
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...')

+ 1 - 1
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()

+ 1 - 1
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):

+ 1 - 1
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')
 

+ 1 - 1
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: