Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: delta_diff_generator.cc

Issue 6551015: AU: When checking if we've visited a file before, don't follow symlinks. (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: unittest Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | delta_performer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/delta_diff_generator.h" 5 #include "update_engine/delta_diff_generator.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <inttypes.h> 9 #include <inttypes.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Make sure we visit each inode only once. 155 // Make sure we visit each inode only once.
156 if (utils::SetContainsKey(visited_inodes, fs_iter.GetStat().st_ino)) 156 if (utils::SetContainsKey(visited_inodes, fs_iter.GetStat().st_ino))
157 continue; 157 continue;
158 visited_inodes.insert(fs_iter.GetStat().st_ino); 158 visited_inodes.insert(fs_iter.GetStat().st_ino);
159 if (fs_iter.GetStat().st_size == 0) 159 if (fs_iter.GetStat().st_size == 0)
160 continue; 160 continue;
161 161
162 LOG(INFO) << "Encoding file " << fs_iter.GetPartialPath(); 162 LOG(INFO) << "Encoding file " << fs_iter.GetPartialPath();
163 163
164 // We can't visit each dst image inode more than once, as that would 164 // We can't visit each dst image inode more than once, as that would
petkov 2011/02/22 23:25:32 Update the comment to reflect the fact that we nev
165 // duplicate work. Here, we avoid visiting each source image inode 165 // duplicate work. Here, we avoid visiting each source image inode
166 // more than once. Technically, we could have multiple operations 166 // more than once. Technically, we could have multiple operations
167 // that read the same blocks from the source image for diffing, but 167 // that read the same blocks from the source image for diffing, but
168 // we choose not to to avoid complexity. Eventually we will move away 168 // we choose not to to avoid complexity. Eventually we will move away
169 // from using a graph/cycle detection/etc to generate diffs, and at that 169 // from using a graph/cycle detection/etc to generate diffs, and at that
170 // time, it will be easy (non-complex) to have many operations read 170 // time, it will be easy (non-complex) to have many operations read
171 // from the same source blocks. At that time, this code can die. -adlr 171 // from the same source blocks. At that time, this code can die. -adlr
172 bool should_diff_from_source = true; 172 bool should_diff_from_source = false;
173 string src_path = old_root + fs_iter.GetPartialPath(); 173 string src_path = old_root + fs_iter.GetPartialPath();
174 if (utils::FileExists(src_path.c_str())) { 174 struct stat src_stbuf;
175 struct stat src_stbuf; 175 if (0 == lstat(src_path.c_str(), &src_stbuf) &&
176 TEST_AND_RETURN_FALSE_ERRNO(0 == stat(src_path.c_str(), &src_stbuf)); 176 S_ISREG(src_stbuf.st_mode)) {
177 should_diff_from_source = !utils::SetContainsKey(visited_src_inodes, 177 should_diff_from_source = !utils::SetContainsKey(visited_src_inodes,
178 src_stbuf.st_ino); 178 src_stbuf.st_ino);
179 visited_src_inodes.insert(src_stbuf.st_ino); 179 visited_src_inodes.insert(src_stbuf.st_ino);
180 } 180 }
181 181
182 TEST_AND_RETURN_FALSE(DeltaReadFile(graph, 182 TEST_AND_RETURN_FALSE(DeltaReadFile(graph,
183 Vertex::kInvalidIndex, 183 Vertex::kInvalidIndex,
184 blocks, 184 blocks,
185 (should_diff_from_source ? 185 (should_diff_from_source ?
186 old_root : 186 old_root :
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 dummy_extent->set_start_block(kSparseHole); 1626 dummy_extent->set_start_block(kSparseHole);
1627 dummy_extent->set_num_blocks((signature_blob_length + kBlockSize - 1) / 1627 dummy_extent->set_num_blocks((signature_blob_length + kBlockSize - 1) /
1628 kBlockSize); 1628 kBlockSize);
1629 } 1629 }
1630 1630
1631 const char* const kBsdiffPath = "bsdiff"; 1631 const char* const kBsdiffPath = "bsdiff";
1632 const char* const kBspatchPath = "bspatch"; 1632 const char* const kBspatchPath = "bspatch";
1633 const char* const kDeltaMagic = "CrAU"; 1633 const char* const kDeltaMagic = "CrAU";
1634 1634
1635 }; // namespace chromeos_update_engine 1635 }; // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « no previous file | delta_performer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698