adding --cache-validity option

This commit is contained in:
Lionel Dricot 2021-12-16 15:58:05 +01:00
parent 9d5a1a9e4c
commit 8ede39dd4d
2 changed files with 7 additions and 4 deletions

View File

@ -5,7 +5,7 @@ This fork is an experiment by Ploum ( gemini://rawtext.club/~ploum) to add offli
In AV-98, use the commands "online" and "offline" to switch between offline/online.
While offline, only content cached in .cache/av-98/ is accessed.
Use "av-98.py --sync" to build a cache containing your bookmarks and all links in your bookmarks. It might be quite slow the first time, be patient.
Use "av-98.py --sync" to build a cache containing your bookmarks and all links in your bookmarks. It might be quite slow the first time, be patient. You can also use the option "--cache-validity 3600" to only refresh cache which are at least 1h old (set the number of seconds according to your needs).
Uncached ressources tentatively accessed offline will be accessed with the next --sync, including reload of already cached ressources.
@ -19,7 +19,6 @@ Known issues in the code:
* TODO: number of cache updated in blackbox
* TODO: dont add to tour when sync from tour/to_fetch
* TODO: dont refresh is cache is young, even for bm
* TODO: https:// gemini:// should be understood without go
This is a fork of the original [AV-98](https://tildegit.org/solderpunk/AV-98)

View File

@ -1754,6 +1754,8 @@ def main():
parser.add_argument('--restricted', action="store_true", help='Disallow shell, add, and save commands')
parser.add_argument('--sync', action='store_true',
help='run non-interactively to build cache by exploring bookmarks')
parser.add_argument('--cache-validity',
help='duration for which a cache is valid before sync (seconds)')
parser.add_argument('--version', action='store_true',
help='display version information and quit')
parser.add_argument('url', metavar='URL', nargs='*',
@ -1818,7 +1820,10 @@ def main():
# Endless interpret loop
if args.sync:
# Dont refresh is cache is younger than 1h
refresh_time = 3600
if args.cache_validity:
refresh_time = int(args.cache_validity)
else:
refresh_time = 1
gc.sync_only = True
# First we get ressources from syncfile
lines_lookup = []
@ -1834,7 +1839,6 @@ def main():
lines_lookup += tf.readlines()
tf.close
gc.onecmd("bm")
#gc.onecmd("go rawtext.club/~ploum/")
original_lookup = []
for l in lines_lookup:
original_lookup.append(GeminiItem(l))