From 1fff962e45ec33c84f6817031146a58fa4f82ede Mon Sep 17 00:00:00 2001 From: Lionel Dricot Date: Sat, 4 Dec 2021 19:52:08 +0100 Subject: [PATCH] bad code to have cache_path --- av98.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/av98.py b/av98.py index 2245407..d00314b 100755 --- a/av98.py +++ b/av98.py @@ -58,6 +58,7 @@ _VERSION = "1.0.4dev" _MAX_REDIRECTS = 5 _MAX_CACHE_SIZE = 10 _MAX_CACHE_AGE_SECS = 180 +_CACHE_PATH = "~/.local/" # Command abbreviations _ABBREVS = { @@ -139,11 +140,20 @@ class GeminiItem(): self.host = parsed.hostname self.port = parsed.port or standard_ports.get(self.scheme, 0) self.path = parsed.path + self.cache_path = None if self.host == None: h = self.url.split('/') self.host = h[0:len(h)-1] self.local = True self.scheme = 'local' + else: + #if not local, we create a local cache path. + self.cache_path = _CACHE_PATH + self.host + self.path + # FIXME : this is a gross hack to give a name to + # index files. This will break if the index is not + # index.gmi + if self.cache_path.endswith("/"): + self.cache_path += "index.gmi" def root(self): return GeminiItem(self._derive_url("/")) @@ -548,7 +558,7 @@ you'll be able to transparently follow links to Gopherspace!""") ## Write ## This is a copy of the raw gemtext tmpf = tempfile.NamedTemporaryFile(mode, encoding=encoding, delete=False) - print("line 550: %s - %s - %s",tmpf.name,gi.url,mime) + print("line 550: ",gi.cache_path) size = tmpf.write(body) tmpf.close() self.tmp_filename = tmpf.name