mirror of
https://github.com/markqvist/NomadNet.git
synced 2026-11-29 03:16:40 -05:00
Use local cache dir
This commit is contained in:
parent
8d4daed978
commit
0b3f96e06a
2 changed files with 11 additions and 7 deletions
|
|
@ -113,7 +113,8 @@ class NomadNetworkApp:
|
||||||
self.identitypath = self.configdir+"/storage/identity"
|
self.identitypath = self.configdir+"/storage/identity"
|
||||||
self.cachepath = self.configdir+"/storage/cache"
|
self.cachepath = self.configdir+"/storage/cache"
|
||||||
self.imagecachepath = self.configdir+"/storage/cache/images"
|
self.imagecachepath = self.configdir+"/storage/cache/images"
|
||||||
self.convcachepath = self.configdir+"/storage/cache/images/converted"
|
self.convcachepath = self.configdir+"/storage/cache/images/converted_node"
|
||||||
|
self.dispcachepath = self.configdir+"/storage/cache/images/converted_disp"
|
||||||
self.resourcepath = self.configdir+"/storage/resources"
|
self.resourcepath = self.configdir+"/storage/resources"
|
||||||
self.conversationpath = self.configdir+"/storage/conversations"
|
self.conversationpath = self.configdir+"/storage/conversations"
|
||||||
self.directorypath = self.configdir+"/storage/directory"
|
self.directorypath = self.configdir+"/storage/directory"
|
||||||
|
|
@ -183,6 +184,9 @@ class NomadNetworkApp:
|
||||||
if not os.path.isdir(self.convcachepath):
|
if not os.path.isdir(self.convcachepath):
|
||||||
os.makedirs(self.convcachepath)
|
os.makedirs(self.convcachepath)
|
||||||
|
|
||||||
|
if not os.path.isdir(self.dispcachepath):
|
||||||
|
os.makedirs(self.dispcachepath)
|
||||||
|
|
||||||
if not os.path.isdir(self.resourcepath):
|
if not os.path.isdir(self.resourcepath):
|
||||||
os.makedirs(self.resourcepath)
|
os.makedirs(self.resourcepath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
# Environment overrides:
|
# Environment overrides:
|
||||||
#
|
#
|
||||||
# NOMADNET_IMAGE_BACKEND force a specific backend (strict)
|
# NOMADNET_IMAGE_BACKEND force a specific backend (strict)
|
||||||
# NOMADNET_IMAGE_CACHE override the conversion cache directory
|
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import ctypes.util
|
import ctypes.util
|
||||||
|
|
@ -115,12 +114,13 @@ def _encode_png_rgba(rgba, width, height):
|
||||||
# Conversion cache #
|
# Conversion cache #
|
||||||
####################
|
####################
|
||||||
|
|
||||||
|
CONV_CACHE_BASE = None
|
||||||
def cache_dir():
|
def cache_dir():
|
||||||
base = os.environ.get("NOMADNET_IMAGE_CACHE")
|
global CONV_CACHE_BASE
|
||||||
if not base:
|
if not CONV_CACHE_BASE:
|
||||||
base = os.environ.get("XDG_CACHE_HOME") or os.path.join(os.path.expanduser("~"), ".cache")
|
from nomadnet.NomadNetworkApp import NomadNetworkApp
|
||||||
base = os.path.join(base, "nomadnet", "image-cache")
|
CONV_CACHE_BASE = NomadNetworkApp._shared_instance.dispcachepath
|
||||||
return base
|
return CONV_CACHE_BASE
|
||||||
|
|
||||||
def _cache_path(source_data):
|
def _cache_path(source_data):
|
||||||
return os.path.join(cache_dir(), hashlib.sha256(source_data).hexdigest() + ".png")
|
return os.path.join(cache_dir(), hashlib.sha256(source_data).hexdigest() + ".png")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue