-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into issue205
- Loading branch information
Showing
8 changed files
with
2,225 additions
and
1,356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Caching utilities""" | ||
from pathlib import Path | ||
|
||
from diskcache import Cache | ||
|
||
|
||
def is_document_modified(key: str, path: Path, cache: Cache) -> bool: | ||
""" | ||
Checks whether a particular document was modified | ||
We can currently afford to naively just stat() the file_path in order to determine it | ||
""" | ||
mtime = cache.get(f"{key}_meta") | ||
if not mtime: | ||
# No information for the book was found, so return True just to be safe | ||
# TODO: Is this acceptable? | ||
return True | ||
stat_mtime = path.stat().st_mtime | ||
return mtime != stat_mtime | ||
|
||
def set_document_modified_time(key: str, path: Path, cache: Cache) -> bool: | ||
key = f"{key}_meta" | ||
cache.set(key, path.stat().st_mtime) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.