Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The LUCI Authors. All rights reserved. | 2 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Archives a set of files or directories to an Isolate Server.""" | 6 """Archives a set of files or directories to an Isolate Server.""" |
| 7 | 7 |
| 8 __version__ = '0.4.8' | 8 __version__ = '0.4.8' |
| 9 | 9 |
| 10 import base64 | 10 import base64 |
| (...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1516 # Report to the server that it failed with more details. We'll want to | 1516 # Report to the server that it failed with more details. We'll want to |
| 1517 # squash them all. | 1517 # squash them all. |
| 1518 on_error.report('Failed to hardlink\n%s -> %s' % (path, dest)) | 1518 on_error.report('Failed to hardlink\n%s -> %s' % (path, dest)) |
| 1519 | 1519 |
| 1520 if file_mode is not None: | 1520 if file_mode is not None: |
| 1521 # Ignores all other bits. | 1521 # Ignores all other bits. |
| 1522 fs.chmod(dest, file_mode & 0500) | 1522 fs.chmod(dest, file_mode & 0500) |
| 1523 with self._lock: | 1523 with self._lock: |
| 1524 self._linked.append(self._lru[digest]) | 1524 self._linked.append(self._lru[digest]) |
| 1525 | 1525 |
| 1526 def item_path(self, digest): | |
| 1527 """Returns a path on disk of the cached item. | |
| 1528 | |
| 1529 Raises: | |
| 1530 CacheMiss if the item is not present in cache. | |
| 1531 """ | |
|
M-A Ruel
2016/06/06 23:34:51
if digest not in self._lru:
raise CacheMiss(dige
nodir
2016/06/07 18:46:35
Done
| |
| 1532 path = self._path(digest) | |
| 1533 if not fs.isfile(path): | |
| 1534 raise CacheMiss(digest) | |
| 1535 return path | |
| 1536 | |
| 1526 def _load(self): | 1537 def _load(self): |
| 1527 """Loads state of the cache from json file.""" | 1538 """Loads state of the cache from json file.""" |
| 1528 self._lock.assert_locked() | 1539 self._lock.assert_locked() |
| 1529 | 1540 |
| 1530 if not os.path.isdir(self.cache_dir): | 1541 if not os.path.isdir(self.cache_dir): |
| 1531 fs.makedirs(self.cache_dir) | 1542 fs.makedirs(self.cache_dir) |
| 1532 else: | 1543 else: |
| 1533 # Make sure the cache is read-only. | 1544 # Make sure the cache is read-only. |
| 1534 # TODO(maruel): Calculate the cost and optimize the performance | 1545 # TODO(maruel): Calculate the cost and optimize the performance |
| 1535 # accordingly. | 1546 # accordingly. |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2287 dispatcher = subcommand.CommandDispatcher(__name__) | 2298 dispatcher = subcommand.CommandDispatcher(__name__) |
| 2288 return dispatcher.execute(OptionParserIsolateServer(), args) | 2299 return dispatcher.execute(OptionParserIsolateServer(), args) |
| 2289 | 2300 |
| 2290 | 2301 |
| 2291 if __name__ == '__main__': | 2302 if __name__ == '__main__': |
| 2292 subprocess42.inhibit_os_error_reporting() | 2303 subprocess42.inhibit_os_error_reporting() |
| 2293 fix_encoding.fix_encoding() | 2304 fix_encoding.fix_encoding() |
| 2294 tools.disable_buffering() | 2305 tools.disable_buffering() |
| 2295 colorama.init() | 2306 colorama.init() |
| 2296 sys.exit(main(sys.argv[1:])) | 2307 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |