URI based Cache filename

Problem: lengthy filenames, have to cut them after 255 chars, sucks with FB, can cause problems
master
pictuga 2013-12-01 15:42:35 +01:00
parent 1a50cb390a
commit c83f5bb23d
1 changed files with 5 additions and 1 deletions

View File

@ -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