# # # patch "database.cc" # from [f3e6f8f1f59ab14f9015c7d63938bd8d91c1b5c1] # to [8b2d7dda1a0273b031f7912ff0b2a25123f6a6c2] # # patch "file_io.cc" # from [a7022c8368fe75b5a41b912d9e3c495fe9be52a8] # to [25cf02fb6d01ce480332afb8d0ab8b6c15c33f4f] # ============================================================ --- database.cc f3e6f8f1f59ab14f9015c7d63938bd8d91c1b5c1 +++ database.cc 8b2d7dda1a0273b031f7912ff0b2a25123f6a6c2 @@ -2766,7 +2766,7 @@ // Try to find a parent to hang this off, otherwise add in full. - hexenc base; + hexenc base_ros; std::set parents; get_revision_parents(rev_id, parents); @@ -2775,24 +2775,30 @@ { if (null_id(*i)) continue; - revision_id old_rev = *i; + hexenc old_ros; + get_roster_id_for_revision(*i, old_ros); std::vector vi; - vlog_id vid = get_existing_vlog_id_for_ident(old_rev.inner()); + vlog_id vid = get_existing_vlog_id_for_ident(old_ros); get_final_vlog_cluster(vid, vi); - if (null_id(base) || vi.back().content == base) - base = vi.back().content; + if (null_id(base_ros) || vi.back().content == base_ros) + base_ros = vi.back().content; } - if (null_id(base)) - put_data(new_id, new_data); + if (null_id(base_ros)) + { + put_data(new_id, new_data); + L(FL("put roster full data '%s'") % new_id); + } else { delta del; gzip gzdel; - get_roster(base, old_data); + get_roster(base_ros, old_data); diff(old_data, new_data, del); encode_gzip(del, gzdel); - put_delta(base, new_id, gzdel); + put_delta(base_ros, new_id, gzdel); + L(FL("put roster delta '%s' -> '%s'") + % base_ros % new_id); } guard.commit(); } @@ -3402,7 +3408,7 @@ "[pos:%d, len:%d] in vlog file '%s'") % vi.back().off % vi.back().len % vlog_pth); data buf; - get_extent_from_file(vlog_pth, vi.front().off, vi.back().len, buf); + get_extent_from_file(vlog_pth, vi.back().off, vi.back().len, buf); del = buf(); return true; } ============================================================ --- file_io.cc a7022c8368fe75b5a41b912d9e3c495fe9be52a8 +++ file_io.cc 25cf02fb6d01ce480332afb8d0ab8b6c15c33f4f @@ -298,9 +298,11 @@ // FIXME: this is probably neither safe nor portable. Just a prototype. int fd = open(path.as_external().c_str(), O_RDONLY|O_LARGEFILE); E(fd != -1, F("open(%s) failed") % path); - E(lseek(fd, off, SEEK_SET) == off, F("lseek() failed")); + if (off != 0) + E(lseek(fd, off, SEEK_SET) == off, F("lseek() failed")); std::string tmp; char buf[constants::bufsz]; + size_t len0 = len; while (len > 0) { size_t count = read(fd, buf, std::min(len, constants::bufsz)); @@ -311,6 +313,7 @@ } dat = data(tmp); E(close(fd) != -1, F("close(%s) failed") % path); + I(dat().size() == len0); }