Modifications to the local database: create a summary segments_used table.
[cumulus.git] / scandir.cc
index 7c940f5..03d8414 100644 (file)
@@ -114,7 +114,7 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path,
      * re-reading the entire contents. */
     bool cached = false;
 
-    if (metawriter->matched() && metawriter->is_unchanged(&stat_buf)) {
+    if (metawriter->find(path) && metawriter->is_unchanged(&stat_buf)) {
         cached = true;
         list<ObjectReference> blocks = metawriter->get_blocks();
 
@@ -248,7 +248,6 @@ void dump_inode(const string& path,         // Path within snapshot
     ssize_t len;
 
     printf("%s\n", path.c_str());
-
     metawriter->find(path);
 
     file_info["name"] = uri_encode(path);
@@ -258,6 +257,11 @@ void dump_inode(const string& path,         // Path within snapshot
     file_info["user"] = encode_int(stat_buf.st_uid);
     file_info["group"] = encode_int(stat_buf.st_gid);
 
+    time_t now = time(NULL);
+    if (now - stat_buf.st_ctime < 30 || now - stat_buf.st_mtime < 30)
+        if ((stat_buf.st_mode & S_IFMT) != S_IFDIR)
+            file_info["volatile"] = "1";
+
     struct passwd *pwd = getpwuid(stat_buf.st_uid);
     if (pwd != NULL) {
         file_info["user"] += " (" + uri_encode(pwd->pw_name) + ")";
@@ -322,6 +326,7 @@ void dump_inode(const string& path,         // Path within snapshot
         if (file_size != stat_buf.st_size) {
             fprintf(stderr, "Warning: Size of %s changed during reading\n",
                     path.c_str());
+            file_info["volatile"] = "1";
         }
 
         break;