X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=store.cc;h=ce54e8717cb195bab45fe8b916ab87eb79cc4e33;hb=5c10647d667fc4408b73402db9247181a54a57ad;hp=ce91e55621d210f82df9a06f9cbaa3c08eb2ff5c;hpb=08147fb0bc1d09610b05f3f7d54eda88ef5776ec;p=cumulus.git diff --git a/store.cc b/store.cc index ce91e55..ce54e87 100644 --- a/store.cc +++ b/store.cc @@ -93,8 +93,8 @@ void Tarfile::internal_write_object(const string &path, static const size_t SEGMENT_SIZE = 4 * 1024 * 1024; -string TarSegmentStore::write_object(const char *data, size_t len, const - std::string &group) +ObjectReference TarSegmentStore::write_object(const char *data, size_t len, + const std::string &group) { struct segment_info *segment; @@ -122,14 +122,14 @@ string TarSegmentStore::write_object(const char *data, size_t len, const segment->file->write_object(id, data, len); segment->count++; - string full_name = segment->name + "/" + id_buf; + ObjectReference ref(segment->name, id_buf); // If this segment meets or exceeds the size target, close it so that // future objects will go into a new segment. if (segment->file->size_estimate() >= SEGMENT_SIZE) close_segment(group); - return full_name; + return ref; } void TarSegmentStore::sync() @@ -168,8 +168,15 @@ void LbsObject::write(TarSegmentStore *store) assert(data != NULL); assert(!written); - name = store->write_object(data, data_len, group); - + ref = store->write_object(data, data_len, group); written = true; - data = NULL; +} + +void LbsObject::checksum() +{ + assert(written); + + SHA1Checksum hash; + hash.process(data, data_len); + ref.set_checksum(hash.checksum_str()); }