| 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 """ |
| 1532 if digest not in self._lru: |
| 1533 raise CacheMiss(digest) |
| 1534 return self._path(digest) |
| 1535 |
| 1526 def _load(self): | 1536 def _load(self): |
| 1527 """Loads state of the cache from json file.""" | 1537 """Loads state of the cache from json file.""" |
| 1528 self._lock.assert_locked() | 1538 self._lock.assert_locked() |
| 1529 | 1539 |
| 1530 if not os.path.isdir(self.cache_dir): | 1540 if not os.path.isdir(self.cache_dir): |
| 1531 fs.makedirs(self.cache_dir) | 1541 fs.makedirs(self.cache_dir) |
| 1532 else: | 1542 else: |
| 1533 # Make sure the cache is read-only. | 1543 # Make sure the cache is read-only. |
| 1534 # TODO(maruel): Calculate the cost and optimize the performance | 1544 # TODO(maruel): Calculate the cost and optimize the performance |
| 1535 # accordingly. | 1545 # accordingly. |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2287 dispatcher = subcommand.CommandDispatcher(__name__) | 2297 dispatcher = subcommand.CommandDispatcher(__name__) |
| 2288 return dispatcher.execute(OptionParserIsolateServer(), args) | 2298 return dispatcher.execute(OptionParserIsolateServer(), args) |
| 2289 | 2299 |
| 2290 | 2300 |
| 2291 if __name__ == '__main__': | 2301 if __name__ == '__main__': |
| 2292 subprocess42.inhibit_os_error_reporting() | 2302 subprocess42.inhibit_os_error_reporting() |
| 2293 fix_encoding.fix_encoding() | 2303 fix_encoding.fix_encoding() |
| 2294 tools.disable_buffering() | 2304 tools.disable_buffering() |
| 2295 colorama.init() | 2305 colorama.init() |
| 2296 sys.exit(main(sys.argv[1:])) | 2306 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |