OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Does one of the following depending on the --mode argument: | 6 """Does one of the following depending on the --mode argument: |
7 check Verifies all the inputs exist, touches the file specified with | 7 check Verifies all the inputs exist, touches the file specified with |
8 --result and exits. | 8 --result and exits. |
9 hashtable Puts a manifest file and hard links each of the inputs into the | 9 hashtable Puts a manifest file and hard links each of the inputs into the |
10 output directory. | 10 output directory. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 filemode &= ~(stat.S_IWGRP | stat.S_IWOTH) | 170 filemode &= ~(stat.S_IWGRP | stat.S_IWOTH) |
171 if read_only: | 171 if read_only: |
172 filemode &= ~stat.S_IWUSR | 172 filemode &= ~stat.S_IWUSR |
173 if filemode & stat.S_IXUSR: | 173 if filemode & stat.S_IXUSR: |
174 filemode |= (stat.S_IXGRP | stat.S_IXOTH) | 174 filemode |= (stat.S_IXGRP | stat.S_IXOTH) |
175 else: | 175 else: |
176 filemode &= ~(stat.S_IXGRP | stat.S_IXOTH) | 176 filemode &= ~(stat.S_IXGRP | stat.S_IXOTH) |
177 outdict[infile]['mode'] = filemode | 177 outdict[infile]['mode'] = filemode |
178 outdict[infile]['size'] = filestats.st_size | 178 outdict[infile]['size'] = filestats.st_size |
179 # Used to skip recalculating the hash. Use the most recent update time. | 179 # Used to skip recalculating the hash. Use the most recent update time. |
180 outdict[infile]['timestamp'] = int(round( | 180 outdict[infile]['timestamp'] = int(round(filestats.st_mtime)) |
181 max(filestats.st_mtime, filestats.st_ctime))) | |
182 # If the timestamp wasn't updated, carry on the sha-1. | 181 # If the timestamp wasn't updated, carry on the sha-1. |
183 if (prevdict.get(infile, {}).get('timestamp') == | 182 if (prevdict.get(infile, {}).get('timestamp') == |
184 outdict[infile]['timestamp'] and | 183 outdict[infile]['timestamp'] and |
185 'sha-1' in prevdict[infile]): | 184 'sha-1' in prevdict[infile]): |
186 # Reuse the previous hash. | 185 # Reuse the previous hash. |
187 outdict[infile]['sha-1'] = prevdict[infile]['sha-1'] | 186 outdict[infile]['sha-1'] = prevdict[infile]['sha-1'] |
188 | 187 |
189 if level >= WITH_HASH and not outdict[infile].get('sha-1'): | 188 if level >= WITH_HASH and not outdict[infile].get('sha-1'): |
190 h = hashlib.sha1() | 189 h = hashlib.sha1() |
191 with open(filepath, 'rb') as f: | 190 with open(filepath, 'rb') as f: |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 command, | 522 command, |
524 relative_dir, | 523 relative_dir, |
525 options.result) | 524 options.result) |
526 except run_test_from_archive.MappingError, e: | 525 except run_test_from_archive.MappingError, e: |
527 print >> sys.stderr, str(e) | 526 print >> sys.stderr, str(e) |
528 return 1 | 527 return 1 |
529 | 528 |
530 | 529 |
531 if __name__ == '__main__': | 530 if __name__ == '__main__': |
532 sys.exit(main()) | 531 sys.exit(main()) |
OLD | NEW |