diff options
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | obnamlib/plugins/backup_plugin.py | 22 | ||||
-rw-r--r-- | yarns/0030-basics.yarn | 20 | ||||
-rw-r--r-- | yarns/9000-implements.yarn | 5 |
4 files changed, 50 insertions, 3 deletions
@@ -31,6 +31,12 @@ Bug fixes: * When restoring from a directory that is not a repository, the error message is now clearer. +* Obnam would previously allow the backup root to be a symbolic link + pointing at a directory. However, this only worked for backups. No + other operations would work and would only see the symbolic link, + not the directory it pointed at. Obnam now gives an error message + even for the backup. + Version 1.7.4, released 2014-03-31 -------------------------------- diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index 8ae7eb35..da24c14e 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -43,6 +43,11 @@ class BackupRootMissingError(obnamlib.ObnamError): msg = 'No backup roots specified' +class BackupRootDoesNotExist(obnamlib.ObnamError): + + msg = 'Backup root does not exist or is not a directory: {root}' + + class BackupErrors(obnamlib.ObnamError): msg = 'There were errors during the backup' @@ -499,8 +504,13 @@ class BackupPlugin(obnamlib.ObnamPlugin): def backup_roots(self, roots): self.progress.what('connecting to to repository') - self.fs = self.app.fsf.new(roots[0]) - self.fs.connect() + try: + self.fs = self.app.fsf.new(roots[0]) + self.fs.connect() + except OSError as e: + if e.errno == errno.ENOENT: + raise BackupRootDoesNotExist(root=roots[0]) + raise absroots = [] for root in roots: @@ -518,7 +528,13 @@ class BackupPlugin(obnamlib.ObnamPlugin): for root in roots: logging.info('Backing up root %s' % root) self.progress.what('connecting to live data %s' % root) - self.fs.reinit(root) + + try: + self.fs.reinit(root) + except OSError as e: + if e.errno == errno.ENOENT: + raise BackupRootDoesNotExist(root=root) + raise self.progress.what('scanning for files in %s' % root) absroot = self.fs.abspath('.') diff --git a/yarns/0030-basics.yarn b/yarns/0030-basics.yarn index 4bc8439b..c753a10c 100644 --- a/yarns/0030-basics.yarn +++ b/yarns/0030-basics.yarn @@ -157,6 +157,26 @@ instead of a file. THEN the attempt succeeded +Backup root is not a directory +------------------------------ + +Obnam does not, currently, support backing up individual files. The +backup root must be a directory. This scenario verifies that Obnam +gives the right error if the root is not a directory. The error code +is R79ED6X, for "Backup root does not exist or is not a directory". + + SCENARIO backup root is not a directory + + GIVEN a symlink L pointing at /dev/null + WHEN user U attempts to back up directory L to repository R + THEN the attempt failed with exit code 1 + THEN the error message matches "R79ED6X" + + GIVEN a file F in ., with data + WHEN user U attempts to back up directory F to repository R + THEN the attempt failed with exit code 1 + THEN the error message matches "R79ED6X" + Backup to roots at once ----------------------- diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn index 4fb0fc00..b348a34f 100644 --- a/yarns/9000-implements.yarn +++ b/yarns/9000-implements.yarn @@ -104,6 +104,11 @@ We need to manipulate extended attributes. mkdir -p $(dirname "$DATADIR/$MATCH_1") setfattr --name="$MATCH_2" --value "$MATCH_3" "$DATADIR/$MATCH_1" +Create a symlink. + + IMPLEMENTS GIVEN a symlink (\S+) pointing at (\S+) + ln -s "$MATCH_2" "$DATADIR/$MATCH_1" + Sometimes we need to remove a file. IMPLEMENTS WHEN user (\S+) removes file (\S+) |