Chromium Code Reviews| Index: delta_diff_generator.cc |
| diff --git a/delta_diff_generator.cc b/delta_diff_generator.cc |
| index 0d1e4cef2360af47c1004c256f762b01d97b646b..e113f7b91734816a1172f803ac25c0485c67c1bd 100644 |
| --- a/delta_diff_generator.cc |
| +++ b/delta_diff_generator.cc |
| @@ -141,6 +141,7 @@ bool DeltaReadFiles(Graph* graph, |
| int data_fd, |
| off_t* data_file_size) { |
| set<ino_t> visited_inodes; |
| + set<ino_t> visited_src_inodes; |
| for (FilesystemIterator fs_iter(new_root, |
| utils::SetWithValue<string>("/lost+found")); |
| !fs_iter.IsEnd(); fs_iter.Increment()) { |
| @@ -156,10 +157,22 @@ bool DeltaReadFiles(Graph* graph, |
| LOG(INFO) << "Encoding file " << fs_iter.GetPartialPath(); |
| + bool should_diff_from_source = true; |
| + string src_path = old_root + fs_iter.GetPartialPath(); |
| + if (utils::FileExists(src_path.c_str())) { |
| + struct stat src_stbuf; |
| + TEST_AND_RETURN_FALSE_ERRNO(0 == stat(src_path.c_str(), &src_stbuf)); |
| + should_diff_from_source = !utils::SetContainsKey(visited_src_inodes, |
|
petkov
2011/02/15 06:01:38
Add a comment what this is trying to catch and wha
|
| + src_stbuf.st_ino); |
| + visited_src_inodes.insert(src_stbuf.st_ino); |
| + } |
| + |
| TEST_AND_RETURN_FALSE(DeltaReadFile(graph, |
| Vertex::kInvalidIndex, |
| blocks, |
| - old_root, |
| + (should_diff_from_source ? |
| + old_root : |
| + "/-!@:&*nonexistent_path"), |
|
petkov
2011/02/15 06:01:38
This feels a bit of a hack. Maybe use an empty str
|
| new_root, |
| fs_iter.GetPartialPath(), |
| data_fd, |