mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-10 03:58:20 +00:00
fix caching
wrong assumption that every filename was unique
This commit is contained in:
parent
fba782fd96
commit
ac835de53b
@ -11,6 +11,7 @@ import glob
|
|||||||
import os
|
import os
|
||||||
from wand import image
|
from wand import image
|
||||||
from wand.exceptions import BlobError as BE
|
from wand.exceptions import BlobError as BE
|
||||||
|
import pathlib
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
@ -26,7 +27,7 @@ def get_dds_as_png(filename):
|
|||||||
|
|
||||||
cache = f'cache/{filename.split(".")[0]}.png'
|
cache = f'cache/{filename.split(".")[0]}.png'
|
||||||
|
|
||||||
if not os.path.exists("app/" + cache):
|
if not os.path.exists(cache):
|
||||||
root = 'app/luclient/res/'
|
root = 'app/luclient/res/'
|
||||||
|
|
||||||
path = glob.glob(
|
path = glob.glob(
|
||||||
@ -75,19 +76,19 @@ def get_icon_lot(id):
|
|||||||
|
|
||||||
filename = filename.replace("..\\", "").replace("\\", "/")
|
filename = filename.replace("..\\", "").replace("\\", "/")
|
||||||
|
|
||||||
cache = f'cache/{filename.split("/")[-1].split(".")[0]}.png'
|
cache = f'app/cache/{filename.split(".")[0]}.png'
|
||||||
|
|
||||||
if not os.path.exists("app/" + cache):
|
if not os.path.exists(cache):
|
||||||
root = 'app/luclient/res/'
|
root = 'app/luclient/res/'
|
||||||
try:
|
try:
|
||||||
|
pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True)
|
||||||
with image.Image(filename=f'{root}{filename}'.lower()) as img:
|
with image.Image(filename=f'{root}{filename}'.lower()) as img:
|
||||||
img.compression = "no"
|
img.compression = "no"
|
||||||
img.save(filename=f'app/cache/{filename.split("/")[-1].split(".")[0]}.png')
|
img.save(filename=cache)
|
||||||
except BE:
|
except BE:
|
||||||
return redirect(url_for('luclient.unknown'))
|
return redirect(url_for('luclient.unknown'))
|
||||||
|
|
||||||
return send_file(cache)
|
return send_file(pathlib.Path(cache).resolve())
|
||||||
|
|
||||||
|
|
||||||
@luclient_blueprint.route('/get_icon_iconid/<id>')
|
@luclient_blueprint.route('/get_icon_iconid/<id>')
|
||||||
@ -102,36 +103,38 @@ def get_icon_iconid(id):
|
|||||||
|
|
||||||
filename = filename.replace("..\\", "").replace("\\", "/")
|
filename = filename.replace("..\\", "").replace("\\", "/")
|
||||||
|
|
||||||
cache = f'cache/{filename.split("/")[-1].split(".")[0]}.png'
|
cache = f'app/cache/{filename.split(".")[0]}.png'
|
||||||
|
|
||||||
if not os.path.exists("app/" + cache):
|
if not os.path.exists(cache):
|
||||||
root = 'app/luclient/res/'
|
root = 'app/luclient/res/'
|
||||||
try:
|
try:
|
||||||
|
pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True)
|
||||||
with image.Image(filename=f'{root}{filename}'.lower()) as img:
|
with image.Image(filename=f'{root}{filename}'.lower()) as img:
|
||||||
img.compression = "no"
|
img.compression = "no"
|
||||||
img.save(filename=f'app/cache/{filename.split("/")[-1].split(".")[0]}.png')
|
img.save(filename=cache)
|
||||||
except BE:
|
except BE:
|
||||||
return redirect(url_for('luclient.unknown'))
|
return redirect(url_for('luclient.unknown'))
|
||||||
|
|
||||||
return send_file(cache)
|
return send_file(pathlib.Path(cache).resolve())
|
||||||
|
|
||||||
@luclient_blueprint.route('/unknown')
|
@luclient_blueprint.route('/unknown')
|
||||||
@login_required
|
@login_required
|
||||||
def unknown():
|
def unknown():
|
||||||
filename = "textures/ui/inventory/unknown.dds"
|
filename = "textures/ui/inventory/unknown.dds"
|
||||||
|
|
||||||
cache = f'cache/{filename.split("/")[-1].split(".")[0]}.png'
|
cache = f'app/cache/{filename.split(".")[0]}.png'
|
||||||
|
|
||||||
if not os.path.exists("app/" + cache):
|
if not os.path.exists(cache):
|
||||||
root = 'app/luclient/res/'
|
root = 'app/luclient/res/'
|
||||||
|
try:
|
||||||
|
pathlib.Path(os.path.dirname(cache)).resolve().mkdir(parents=True, exist_ok=True)
|
||||||
|
with image.Image(filename=f'{root}{filename}'.lower()) as img:
|
||||||
|
img.compression = "no"
|
||||||
|
img.save(filename=cache)
|
||||||
|
except BE:
|
||||||
|
return redirect(url_for('luclient.unknown'))
|
||||||
|
|
||||||
with image.Image(filename=f'{root}{filename}'.lower()) as img:
|
return send_file(pathlib.Path(cache).resolve())
|
||||||
img.compression = "no"
|
|
||||||
img.save(filename=f'app/cache/{filename.split("/")[-1].split(".")[0]}.png')
|
|
||||||
|
|
||||||
|
|
||||||
return send_file(cache)
|
|
||||||
|
|
||||||
|
|
||||||
def get_cdclient():
|
def get_cdclient():
|
||||||
|
Loading…
Reference in New Issue
Block a user