summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-07-01 11:12:46 +1200
committerLars Wirzenius <liw@liw.fi>2010-07-01 11:12:46 +1200
commitc897e5418a859a2893d380477cbdb88f1728b544 (patch)
tree6dec44aa957e9ee3c960189cc1b0b17093cd6820
parentd8880cf041a89858f3dae58b703f6c5808907c49 (diff)
downloadobnam-c897e5418a859a2893d380477cbdb88f1728b544.tar.gz
Only store metadata if it has changed.
B-tree lookups are massively faster than inserts, so this saves time on incremental backups, since most of the time, the metadata does not actually change.
-rw-r--r--obnamlib/store.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/obnamlib/store.py b/obnamlib/store.py
index 00cb94f0..ad2226cc 100644
--- a/obnamlib/store.py
+++ b/obnamlib/store.py
@@ -381,7 +381,13 @@ class GenerationStore(StoreTree):
self.curgen.remove_range(key, key)
def create(self, filename, metadata):
- self.set_metadata(filename, metadata)
+ key = self.key(filename, self.FILE, self.FILE_METADATA)
+ try:
+ old_metadata = self.curgen.lookup(key)
+ except KeyError:
+ old_metadata = None
+ if metadata != old_metadata:
+ self.set_metadata(filename, metadata)
# Add to parent's contents, unless already there.
parent = os.path.dirname(filename)