| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium 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 import posixpath | 5 import posixpath |
| 6 import sys | 6 import sys |
| 7 | 7 |
| 8 from file_system import FileSystem, StatInfo, FileNotFoundError | 8 from file_system import FileSystem, StatInfo, FileNotFoundError |
| 9 from future import Future | 9 from future import Future |
| 10 from path_util import IsDirectory, ToDirectory | 10 from path_util import IsDirectory, ToDirectory |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 self._stat_object_store = create_object_store('stat') | 26 self._stat_object_store = create_object_store('stat') |
| 27 # The read caches can start populated (start_empty=False) because file | 27 # The read caches can start populated (start_empty=False) because file |
| 28 # updates are picked up by the stat, so it doesn't need the force-refresh | 28 # updates are picked up by the stat, so it doesn't need the force-refresh |
| 29 # which starting empty is designed for. Without this optimisation, cron | 29 # which starting empty is designed for. Without this optimisation, cron |
| 30 # runs are extra slow. | 30 # runs are extra slow. |
| 31 self._read_object_store = create_object_store('read', start_empty=False) | 31 self._read_object_store = create_object_store('read', start_empty=False) |
| 32 | 32 |
| 33 def Refresh(self): | 33 def Refresh(self): |
| 34 return self._file_system.Refresh() | 34 return self._file_system.Refresh() |
| 35 | 35 |
| 36 def Stat(self, path): | |
| 37 return self.StatAsync(path).Get() | |
| 38 | |
| 39 def StatAsync(self, path): | 36 def StatAsync(self, path): |
| 40 '''Stats the directory given, or if a file is given, stats the file's parent | 37 '''Stats the directory given, or if a file is given, stats the file's parent |
| 41 directory to get info about the file. | 38 directory to get info about the file. |
| 42 ''' | 39 ''' |
| 43 # Always stat the parent directory, since it will have the stat of the child | 40 # Always stat the parent directory, since it will have the stat of the child |
| 44 # anyway, and this gives us an entire directory's stat info at once. | 41 # anyway, and this gives us an entire directory's stat info at once. |
| 45 dir_path, file_path = posixpath.split(path) | 42 dir_path, file_path = posixpath.split(path) |
| 46 dir_path = ToDirectory(dir_path) | 43 dir_path = ToDirectory(dir_path) |
| 47 | 44 |
| 48 def make_stat_info(dir_stat): | 45 def make_stat_info(dir_stat): |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return new_results | 122 return new_results |
| 126 # Read in the values that were uncached or old. | 123 # Read in the values that were uncached or old. |
| 127 return self._file_system.Read(set(paths) - set(fresh_data.iterkeys()), | 124 return self._file_system.Read(set(paths) - set(fresh_data.iterkeys()), |
| 128 skip_not_found=skip_not_found).Then(next) | 125 skip_not_found=skip_not_found).Then(next) |
| 129 | 126 |
| 130 def GetIdentity(self): | 127 def GetIdentity(self): |
| 131 return self._file_system.GetIdentity() | 128 return self._file_system.GetIdentity() |
| 132 | 129 |
| 133 def __repr__(self): | 130 def __repr__(self): |
| 134 return '%s of <%s>' % (type(self).__name__, repr(self._file_system)) | 131 return '%s of <%s>' % (type(self).__name__, repr(self._file_system)) |
| OLD | NEW |