Report compressed size of data written in a backup as well as uncompressed.
[cumulus.git] / localdb.cc
index 1c44fa4..3cd7111 100644 (file)
@@ -1,5 +1,5 @@
 /* LBS: An LFS-inspired filesystem backup system
- * Copyright (C) 2007  Michael Vrable
+ * Copyright (C) 2007-2008  Michael Vrable
  *
  * When creating backup snapshots, maintain a local database of data blocks and
  * checksums, in addition to the data contents (which may be stored remotely).
@@ -248,10 +248,12 @@ void LocalDb::StoreObject(const ObjectReference& ref,
     sqlite3_finalize(stmt);
 
     if (age != 0.0) {
-        stmt = Prepare("update segments set mtime = max(mtime, ?) "
+        stmt = Prepare("update segments "
+                       "set mtime = coalesce(max(mtime, ?), ?) "
                        "where segmentid = ?");
         sqlite3_bind_double(stmt, 1, age);
-        sqlite3_bind_int64(stmt, 2, SegmentToId(ref.get_segment()));
+        sqlite3_bind_double(stmt, 2, age);
+        sqlite3_bind_int64(stmt, 3, SegmentToId(ref.get_segment()));
         rc = sqlite3_step(stmt);
         sqlite3_finalize(stmt);
     }