Conversation
Originally implemented in #494.
| def is_in_sync(self, folder: Path, force_check: bool = False) -> bool: | ||
| """Check file exists in the given folder and is in sync.""" | ||
| path = folder.joinpath(self.fname) | ||
| return ( | ||
| path.exists() | ||
| and abs(utils.get_mtime(path) - self.mtime) / 1_000_000 | ||
| < MTIME_TOLERANCE_SECS | ||
| ) | ||
| if force_check or self._is_in_sync is None: | ||
| path = folder.joinpath(self.fname) | ||
| self._is_in_sync = ( | ||
| path.exists() | ||
| and abs(utils.get_mtime(path) - self.mtime) / 1_000_000 | ||
| < MTIME_TOLERANCE_SECS | ||
| ) | ||
| return self._is_in_sync |
There was a problem hiding this comment.
I'd make _is_in_sync a property or a function. You could still cache it.
There was a problem hiding this comment.
How exactly? Given it's a method, using @cache seemed more trouble than it's worth.
There was a problem hiding this comment.
I meant the class attribute. I know it's internal, but it seems like a strange attribute for a resourcefile given that the object has no way of knowing if the resource is currently out of sync. Or did you intend on for updates to the attribute to be added in the future?
There was a problem hiding this comment.
I see your point, but don't get what you'd like to see instead.
_is_in_sync is itself a cache for is_in_sync(). It wouldn't work as a function.
There was a problem hiding this comment.
Merging now, but feel free to come back to this.
@bohning, I've reimplemented your feature from #494.
I've taken your icons for the system theme, and chose new Material icons for the dark theme.
Two caveats: