def _SetPath(self, path): old_path = self._path if old_path and not gcs.IsGCSPath(old_path): # We're done with the path, so store its size. size = io_wrapper.Size(old_path) logging.debug('Setting latest size of %s to %d', old_path, size) self._finalized_sizes[old_path] = size self._path = path self._loader = self._loader_factory(path)
def _HasOOOWrite(self, path): """Returns whether the path has had an out-of-order write.""" # Check the sizes of each path before the current one. size = io_wrapper.Size(path) old_size = self._finalized_sizes.get(path, None) if size != old_size: if old_size is None: logging.error('File %s created after file %s even though it\'s ' 'lexicographically earlier', path, self._path) else: logging.error('File %s updated even though the current file is %s', path, self._path) return True else: return False
def _SetPath(self, path): """Sets the current path to watch for new events. This also records the size of the old path, if any. If the size can't be found, an error is logged. Args: path: The full path of the file to watch. """ old_path = self._path if old_path and not gcs.IsGCSPath(old_path): try: # We're done with the path, so store its size. size = io_wrapper.Size(old_path) logging.debug('Setting latest size of %s to %d', old_path, size) self._finalized_sizes[old_path] = size except errors.OpError as e: logging.error('Unable to get size of %s: %s', old_path, e) self._path = path self._loader = self._loader_factory(path)