From 65463770d838a346c25ba559ad4e7a10ffc40bc2 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Fri, 27 Jul 2007 11:58:17 -0700 Subject: [PATCH] Provide a more detailed indication of file status when backing up. Indicate whether a file is new, or whether we managed to find the old data in other segments, or whether data is being copied because we are cleaning segments, etc. --- scandir.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scandir.cc b/scandir.cc index 6e672c6..db0961b 100644 --- a/scandir.cc +++ b/scandir.cc @@ -135,6 +135,7 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, { int64_t size = 0; list object_list; + const char *status = NULL; /* Status indicator printed out */ /* Look up this file in the old stat cache, if we can. If the stat * information indicates that the file has not changed, do not bother @@ -152,6 +153,7 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, const ObjectReference &ref = *i; if (!db->IsAvailable(ref)) { cached = false; + status = "repack"; break; } } @@ -173,8 +175,6 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, /* If the file is new or changed, we must read in the contents a block at a * time. */ if (!cached) { - printf(" [new]\n"); - SHA1Checksum hash; while (true) { ssize_t bytes = file_read(fd, block_buf, LBS_BLOCK_SIZE); @@ -211,10 +211,14 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, * Additionally, keep track of the age of the data by looking * up the age of the block which was expired and using that * instead of the current time. */ - if (db->IsOldObject(block_csum, bytes, &block_age)) + if (db->IsOldObject(block_csum, bytes, &block_age)) { o->set_group("compacted"); - else + if (status == NULL) + status = "partial"; + } else { o->set_group("data"); + status = "new"; + } o->set_data(block_buf, bytes); o->write(tss); @@ -227,11 +231,17 @@ int64_t dumpfile(int fd, dictionary &file_info, const string &path, segment_list.insert(ref.get_segment()); db->UseObject(ref); size += bytes; + + if (status == NULL) + status = "old"; } file_info["checksum"] = hash.checksum_str(); } + if (status != NULL) + printf(" [%s]\n", status); + statcache->Save(path, &stat_buf, file_info["checksum"], object_list); /* For files that only need to be broken apart into a few objects, store -- 2.20.1