Merge lp:~bgeron/apt-btrfs-snapshot/fix-update-fail into lp:apt-btrfs-snapshot

Proposed by Bram Geron
Status: Merged
Merged at revision: 51
Proposed branch: lp:~bgeron/apt-btrfs-snapshot/fix-update-fail
Merge into: lp:apt-btrfs-snapshot
Diff against target: 36 lines (+14/-5)
1 file modified
apt_btrfs_snapshot.py (+14/-5)
To merge this branch: bzr merge lp:~bgeron/apt-btrfs-snapshot/fix-update-fail
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+265996@code.launchpad.net

Description of the change

Fixes #853849 (apt failing when the three snapshots are made in a single second), by skipping "duplicate" snapshots in a single second.

(I made a merge proposal earlier, but it was in the wrong direction.)

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apt_btrfs_snapshot.py'
2--- apt_btrfs_snapshot.py 2013-01-06 02:45:03 +0000
3+++ apt_btrfs_snapshot.py 2015-07-27 16:03:24 +0000
4@@ -25,6 +25,9 @@
5 import time
6 import tempfile
7
8+import gettext
9+from gettext import gettext as _
10+
11
12 class AptBtrfsSnapshotError(Exception):
13 pass
14@@ -163,11 +166,17 @@
15 def create_btrfs_root_snapshot(self, additional_prefix=""):
16 mp = self.mount_btrfs_root_volume()
17 snap_id = self._get_now_str()
18- res = self.commands.btrfs_subvolume_snapshot(
19- os.path.join(mp, "@"),
20- os.path.join(mp, self.SNAP_PREFIX + additional_prefix + snap_id))
21- self.umount_btrfs_root_volume()
22- return res
23+ source = os.path.join(mp, "@")
24+ target = os.path.join(mp, self.SNAP_PREFIX + additional_prefix + snap_id)
25+
26+ if os.path.exists(target):
27+ print(_("INFO: snapshot directory '%s' already exists, not creating duplicate")
28+ % (target,))
29+ return True
30+ else:
31+ res = self.commands.btrfs_subvolume_snapshot(source, target)
32+ self.umount_btrfs_root_volume()
33+ return res
34
35 def get_btrfs_root_snapshots_list(self, older_than=0):
36 """ get the list of available snapshot

Subscribers

People subscribed via source and target branches

to all changes: