From bd4a0fe23b50ddb1e5383255f301db06208d7972 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Fri, 11 Nov 2016 21:24:16 +0100 Subject: [PATCH] Clarify cache/repository README file --- src/borg/cache.py | 3 ++- src/borg/constants.py | 9 +++++++++ src/borg/repository.py | 2 +- src/borg/upgrader.py | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/borg/cache.py b/src/borg/cache.py index 3ed33d742..e2ce3651b 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -10,6 +10,7 @@ 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 @@ def create(self): """ 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') diff --git a/src/borg/constants.py b/src/borg/constants.py index d6f26d116..27ad8c297 100644 --- a/src/borg/constants.py +++ b/src/borg/constants.py @@ -50,3 +50,12 @@ 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/ +""" diff --git a/src/borg/repository.py b/src/borg/repository.py index 89374d6f7..a4366f773 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -166,7 +166,7 @@ def create(self, path): 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') diff --git a/src/borg/upgrader.py b/src/borg/upgrader.py index 69712832a..78da849a2 100644 --- a/src/borg/upgrader.py +++ b/src/borg/upgrader.py @@ -6,6 +6,7 @@ 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 @@ def borg_readme(self): 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):