X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=statcache.cc;h=099eb708ae3c7a9688cf438fee75e4e4c689376e;hb=79c9c740d9b78e357dd66cb9a4b77d03a5076f3b;hp=db0779245651a19f61465d4f642a6abd95b91fe9;hpb=80f96acfb98a06327a66bc97c81bdc190103340b;p=cumulus.git diff --git a/statcache.cc b/statcache.cc index db07792..099eb70 100644 --- a/statcache.cc +++ b/statcache.cc @@ -30,9 +30,9 @@ #include #include -#include "format.h" #include "ref.h" #include "statcache.h" +#include "util.h" using std::list; using std::map; @@ -79,10 +79,13 @@ static int pathcmp(const char *path1, const char *path2) return pathcmp(slash1 + 1, slash2 + 1); } -void StatCache::Open(const char *path, const char *snapshot_name) +void StatCache::Open(const char *path, const char *snapshot_name, + const char *snapshot_scheme) { oldpath = path; oldpath += "/statcache"; + if (snapshot_scheme != NULL) + oldpath = oldpath + "-" + snapshot_scheme; newpath = oldpath + "." + snapshot_name; oldcache = new ifstream(oldpath.c_str()); @@ -121,15 +124,17 @@ void StatCache::ReadNext() old_mtime = -1; old_ctime = -1; old_inode = -1; + old_size = -1; old_checksum = ""; old_contents.clear(); - /* First, read in the filename. TODO: Unescaping. */ + /* First, read in the filename. */ getline(cache, old_name); if (!cache) { end_of_cache = true; return; } + old_name = uri_decode(old_name); /* Start reading in the fields which follow the filename. */ string field = ""; @@ -171,6 +176,8 @@ void StatCache::ReadNext() old_ctime = parse_int(fields["ctime"]); if (fields.count("inode")) old_inode = parse_int(fields["inode"]); + if (fields.count("size")) + old_size = parse_int(fields["size"]); old_checksum = fields["checksum"]; @@ -225,6 +232,8 @@ bool StatCache::Find(const string &path, const struct stat *stat_buf) return false; if ((long long)stat_buf->st_ino != old_inode) return false; + if (stat_buf->st_size != old_size) + return false; /* File looks to be unchanged. */ return true; @@ -254,6 +263,7 @@ void StatCache::Save(const string &path, struct stat *stat_buf, *newcache << "mtime: " << encode_int(stat_buf->st_mtime) << "\n" << "ctime: " << encode_int(stat_buf->st_ctime) << "\n" << "inode: " << encode_int(stat_buf->st_ino) << "\n" + << "size: " << encode_int(stat_buf->st_size) << "\n" << "checksum: " << checksum << "\n"; *newcache << "blocks:";