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

Merge pull request #1834 from enkore/issue/1813

Clarify cache/repository README file
enkore 8 жил өмнө
parent
commit
e26348a055

+ 2 - 1
src/borg/cache.py

@@ -10,6 +10,7 @@ import msgpack
 from .logger import create_logger
 logger = create_logger()
 
+from .constants import CACHE_README
 from .hashindex import ChunkIndex, ChunkIndexEntry
 from .helpers import Location
 from .helpers import Error
@@ -151,7 +152,7 @@ Chunk index:    {0.total_unique_chunks:20d} {0.total_chunks:20d}"""
         """
         os.makedirs(self.path)
         with open(os.path.join(self.path, 'README'), 'w') as fd:
-            fd.write('This is a Borg cache')
+            fd.write(CACHE_README)
         config = configparser.ConfigParser(interpolation=None)
         config.add_section('cache')
         config.set('cache', 'version', '1')

+ 9 - 0
src/borg/constants.py

@@ -50,3 +50,12 @@ EXIT_ERROR = 2  # terminated abruptly, did not reach end of operation
 DASHES = '-' * 78
 
 PBKDF2_ITERATIONS = 100000
+
+
+REPOSITORY_README = """This is a Borg Backup repository.
+See https://borgbackup.readthedocs.io/
+"""
+
+CACHE_README = """This is a Borg Backup cache.
+See https://borgbackup.readthedocs.io/
+"""

+ 1 - 1
src/borg/repository.py

@@ -166,7 +166,7 @@ class Repository:
         if not os.path.exists(path):
             os.mkdir(path)
         with open(os.path.join(path, 'README'), 'w') as fd:
-            fd.write('This is a Borg repository\n')
+            fd.write(REPOSITORY_README)
         os.mkdir(os.path.join(path, 'data'))
         config = ConfigParser(interpolation=None)
         config.add_section('repository')

+ 2 - 1
src/borg/upgrader.py

@@ -6,6 +6,7 @@ import time
 import logging
 logger = logging.getLogger(__name__)
 
+from .constants import REPOSITORY_README
 from .helpers import get_home_dir, get_keys_dir, get_cache_dir
 from .helpers import ProgressIndicatorPercent
 from .key import KeyfileKey, KeyfileNotFoundError
@@ -64,7 +65,7 @@ class AtticRepositoryUpgrader(Repository):
         readme = os.path.join(self.path, 'README')
         os.remove(readme)
         with open(readme, 'w') as fd:
-            fd.write('This is a Borg repository\n')
+            fd.write(REPOSITORY_README)
 
     @staticmethod
     def convert_segments(segments, dryrun=True, inplace=False, progress=False):