(self, paths: Iterable[str])
| 63 | self._file_data[path] = FileData(st.st_mtime, st.st_size, hash_digest) |
| 64 | |
| 65 | def _find_changed(self, paths: Iterable[str]) -> AbstractSet[str]: |
| 66 | changed = set() |
| 67 | for path in paths: |
| 68 | old = self._file_data[path] |
| 69 | st = self.fs.stat_or_none(path) |
| 70 | if st is None: |
| 71 | if old is not None: |
| 72 | # File was deleted. |
| 73 | changed.add(path) |
| 74 | self._file_data[path] = None |
| 75 | else: |
| 76 | if old is None: |
| 77 | # File is new. |
| 78 | changed.add(path) |
| 79 | self._update(path, st) |
| 80 | # Round mtimes down, to match the mtimes we write to meta files |
| 81 | elif st.st_size != old.st_size or int(st.st_mtime) != int(old.st_mtime): |
| 82 | # Only look for changes if size or mtime has changed as an |
| 83 | # optimization, since calculating hash is expensive. |
| 84 | new_hash = self.fs.hash_digest(path) |
| 85 | self._update(path, st) |
| 86 | if st.st_size != old.st_size or new_hash != old.hash: |
| 87 | # Changed file. |
| 88 | changed.add(path) |
| 89 | return changed |
| 90 | |
| 91 | def find_changed(self) -> AbstractSet[str]: |
| 92 | """Return paths that have changes since the last call, in the watched set.""" |
no test coverage detected