From c83f5bb23d562aaee031a03f69bdf51b88b3b0db Mon Sep 17 00:00:00 2001 From: pictuga Date: Sun, 1 Dec 2013 15:42:35 +0100 Subject: [PATCH] URI based Cache filename Problem: lengthy filenames, have to cut them after 255 chars, sucks with FB, can cause problems --- morss.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/morss.py b/morss.py index f0becea..7340527 100644 --- a/morss.py +++ b/morss.py @@ -21,6 +21,7 @@ import feeds import feedify import httplib +import urllib import urllib2 import socket import chardet @@ -127,8 +128,11 @@ class Cache: """ Light, error-prone caching system. """ def __init__(self, folder, key, persistent=False): self._key = key - self._hash = b64encode(self._key) self._dir = folder + + maxsize = os.statvfs('./').f_namemax - len(self._dir) - 1 + self._hash = urllib.quote_plus(self._key)[:maxsize] + self._file = self._dir + '/' + self._hash self._cached = {} # what *was* cached