X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=metadata.cc;h=f972b75999598e562c3ded4788b9b1550b12c47f;hb=0347920b621a8feaf16d5f48f33bbe1b238fc896;hp=dac3d20b1aba6d61866d699005516a016f94e446;hpb=fbb042e3bbfe0796b0986fa0ffa9cde75c6e3bce;p=cumulus.git diff --git a/metadata.cc b/metadata.cc index dac3d20..f972b75 100644 --- a/metadata.cc +++ b/metadata.cc @@ -106,7 +106,6 @@ MetadataWriter::MetadataWriter(TarSegmentStore *store, throw IOException("Error opening statcache"); } - found_match = false; old_metadata_eof = false; this->store = store; @@ -187,28 +186,25 @@ bool MetadataWriter::find(const string& path) while (!old_metadata_eof) { string old_path = uri_decode(old_metadata["name"]); int cmp = pathcmp(old_path.c_str(), path_str); - if (cmp == 0) { - found_match = true; + if (cmp == 0) return true; - } else if (cmp > 0) { - found_match = false; + else if (cmp > 0) return false; - } else { + else read_statcache(); - } } - found_match = false; return false; } /* Does a file appear to be unchanged from the previous time it was backed up, - * based on stat information? - * - * TODO: Notice files that were modified as they were being backed up the last - * time. */ + * based on stat information? */ bool MetadataWriter::is_unchanged(const struct stat *stat_buf) { + if (old_metadata.find("volatile") != old_metadata.end() + && parse_int(old_metadata["volatile"]) != 0) + return false; + if (old_metadata.find("ctime") == old_metadata.end()) return false; if (stat_buf->st_ctime != parse_int(old_metadata["ctime"])) @@ -256,11 +252,9 @@ list MetadataWriter::get_blocks() s++; } - ObjectReference *r = ObjectReference::parse(ref); - if (r != NULL) { - blocks.push_back(*r); - delete r; - } + ObjectReference r = ObjectReference::parse(ref); + if (!r.is_null()) + blocks.push_back(r); } return blocks; @@ -350,11 +344,10 @@ void MetadataWriter::add(dictionary info) item.text += encode_dict(info) + "\n"; if (info == old_metadata) { - ObjectReference *ref = ObjectReference::parse(old_metadata_loc); - if (ref != NULL) { + ObjectReference ref = ObjectReference::parse(old_metadata_loc); + if (!ref.is_null()) { item.reused = true; - item.ref = *ref; - delete ref; + item.ref = ref; } }