Write out new-style statcache data.
[cumulus.git] / scandir.cc
index 49d8c32..4f84955 100644 (file)
@@ -229,33 +229,14 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path,
 
     statcache->Save(path, &stat_buf, file_info["checksum"], object_list);
 
-    /* For files that only need to be broken apart into a few objects, store
-     * the list of objects directly.  For larger files, store the data
-     * out-of-line and provide a pointer to the indrect object. */
-    if (object_list.size() < 8) {
-        string blocklist = "";
-        for (list<string>::iterator i = object_list.begin();
-             i != object_list.end(); ++i) {
-            if (i != object_list.begin())
-                blocklist += " ";
-            blocklist += *i;
-        }
-        file_info["data"] = blocklist;
-    } else {
-        string blocklist = "";
-        for (list<string>::iterator i = object_list.begin();
-             i != object_list.end(); ++i) {
-            blocklist += *i + "\n";
-        }
-
-        LbsObject *i = new LbsObject;
-        i->set_group("metadata");
-        i->set_data(blocklist.data(), blocklist.size());
-        i->write(tss);
-        file_info["data"] = "@" + i->get_name();
-        segment_list.insert(i->get_ref().get_segment());
-        delete i;
+    string blocklist = "";
+    for (list<string>::iterator i = object_list.begin();
+         i != object_list.end(); ++i) {
+        if (i != object_list.begin())
+            blocklist += "\n    ";
+        blocklist += *i;
     }
+    file_info["data"] = blocklist;
 
     return size;
 }
@@ -276,6 +257,7 @@ void dump_inode(const string& path,         // Path within snapshot
     printf("%s\n", path.c_str());
 
     file_info["mode"] = encode_int(stat_buf.st_mode & 07777, 8);
+    file_info["ctime"] = encode_int(stat_buf.st_ctime);
     file_info["mtime"] = encode_int(stat_buf.st_mtime);
     file_info["user"] = encode_int(stat_buf.st_uid);
     file_info["group"] = encode_int(stat_buf.st_gid);
@@ -292,11 +274,12 @@ void dump_inode(const string& path,         // Path within snapshot
 
     if (stat_buf.st_nlink > 1 && (stat_buf.st_mode & S_IFMT) != S_IFDIR) {
         file_info["links"] = encode_int(stat_buf.st_nlink);
-        file_info["inode"] = encode_int(major(stat_buf.st_dev))
-            + "/" + encode_int(minor(stat_buf.st_dev))
-            + "/" + encode_int(stat_buf.st_ino);
     }
 
+    file_info["inode"] = encode_int(major(stat_buf.st_dev))
+        + "/" + encode_int(minor(stat_buf.st_dev))
+        + "/" + encode_int(stat_buf.st_ino);
+
     char inode_type;
 
     switch (stat_buf.st_mode & S_IFMT) {
@@ -683,13 +666,16 @@ int main(int argc, char *argv[])
 
     tss = new TarSegmentStore(backup_dest, db);
 
-    metawriter = new MetadataWriter(tss);
-
     /* Initialize the stat cache, for skipping over unchanged files. */
     statcache = new StatCache;
     statcache->Open(localdb_dir.c_str(), desc_buf,
                     backup_scheme.size() ? backup_scheme.c_str() : NULL);
 
+    metawriter = new MetadataWriter(tss, localdb_dir.c_str(), desc_buf,
+                                    backup_scheme.size()
+                                        ? backup_scheme.c_str()
+                                        : NULL);
+
     scanfile(".", false);
 
     ObjectReference root_ref = metawriter->close();