| 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.6.0' | 8 __version__ = '0.6.0' |
| 9 | 9 |
| 10 import base64 | 10 import base64 |
| (...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 self._save() | 1747 self._save() |
| 1748 | 1748 |
| 1749 def _path(self, digest): | 1749 def _path(self, digest): |
| 1750 """Returns the path to one item.""" | 1750 """Returns the path to one item.""" |
| 1751 return os.path.join(self.cache_dir, digest) | 1751 return os.path.join(self.cache_dir, digest) |
| 1752 | 1752 |
| 1753 def _remove_lru_file(self, allow_protected): | 1753 def _remove_lru_file(self, allow_protected): |
| 1754 """Removes the lastest recently used file and returns its size.""" | 1754 """Removes the lastest recently used file and returns its size.""" |
| 1755 self._lock.assert_locked() | 1755 self._lock.assert_locked() |
| 1756 try: | 1756 try: |
| 1757 digest, size = self._lru.get_oldest() | 1757 digest, (size, _) = self._lru.get_oldest() |
| 1758 if not allow_protected and digest == self._protected: | 1758 if not allow_protected and digest == self._protected: |
| 1759 raise Error('Not enough space to map the whole isolated tree') | 1759 raise Error('Not enough space to map the whole isolated tree') |
| 1760 except KeyError: | 1760 except KeyError: |
| 1761 raise Error('Nothing to remove') | 1761 raise Error('Nothing to remove') |
| 1762 digest, size = self._lru.pop_oldest() | 1762 digest, (size, _) = self._lru.pop_oldest() |
| 1763 logging.debug("Removing LRU file %s", digest) | 1763 logging.debug("Removing LRU file %s", digest) |
| 1764 self._delete_file(digest, size) | 1764 self._delete_file(digest, size) |
| 1765 return size | 1765 return size |
| 1766 | 1766 |
| 1767 def _add(self, digest, size=UNKNOWN_FILE_SIZE): | 1767 def _add(self, digest, size=UNKNOWN_FILE_SIZE): |
| 1768 """Adds an item into LRU cache marking it as a newest one.""" | 1768 """Adds an item into LRU cache marking it as a newest one.""" |
| 1769 self._lock.assert_locked() | 1769 self._lock.assert_locked() |
| 1770 if size == UNKNOWN_FILE_SIZE: | 1770 if size == UNKNOWN_FILE_SIZE: |
| 1771 size = fs.stat(self._path(digest)).st_size | 1771 size = fs.stat(self._path(digest)).st_size |
| 1772 self._added.append(size) | 1772 self._added.append(size) |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2431 return dispatcher.execute(OptionParserIsolateServer(), args) | 2431 return dispatcher.execute(OptionParserIsolateServer(), args) |
| 2432 | 2432 |
| 2433 | 2433 |
| 2434 if __name__ == '__main__': | 2434 if __name__ == '__main__': |
| 2435 subprocess42.inhibit_os_error_reporting() | 2435 subprocess42.inhibit_os_error_reporting() |
| 2436 fix_encoding.fix_encoding() | 2436 fix_encoding.fix_encoding() |
| 2437 tools.disable_buffering() | 2437 tools.disable_buffering() |
| 2438 colorama.init() | 2438 colorama.init() |
| 2439 file_path.enable_symlink() | 2439 file_path.enable_symlink() |
| 2440 sys.exit(main(sys.argv[1:])) | 2440 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |