mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-21 13:07:22 +00:00
use cache more modified files
so that the client dir never has to be written to
This commit is contained in:
parent
0fea032938
commit
785357475d
@ -11,6 +11,7 @@ from flask_user import user_registered, current_user, user_logged_in
|
||||
from flask_wtf.csrf import CSRFProtect
|
||||
from flask_apscheduler import APScheduler
|
||||
from app.luclient import register_luclient_jinja_helpers
|
||||
import pathlib
|
||||
|
||||
from app.commands import (
|
||||
init_db,
|
||||
@ -101,6 +102,15 @@ def create_app():
|
||||
register_blueprints(app)
|
||||
register_luclient_jinja_helpers(app)
|
||||
|
||||
# Extract the brickdb if it's not already extracted
|
||||
materials = pathlib.Path(f'{app.config["CACHE_LOCATION"]}Materials.xml')
|
||||
if not materials.is_file():
|
||||
from zipfile import ZipFile
|
||||
with ZipFile(f"{app.config['CLIENT_LOCATION']}res/brickdb.zip","r") as zip_ref:
|
||||
zip_ref.extractall(app.config["CACHE_LOCATION"])
|
||||
from shutil import copytree
|
||||
copytree(f"{app.config['CLIENT_LOCATION']}res/brickprimitives", f"{app.config['CACHE_LOCATION']}brickprimitives")
|
||||
|
||||
return app
|
||||
|
||||
|
||||
@ -269,6 +279,7 @@ def register_settings(app):
|
||||
'USER_EMAIL_SENDER_EMAIL',
|
||||
app.config['USER_EMAIL_SENDER_EMAIL']
|
||||
)
|
||||
|
||||
if "ENABLE_CHAR_XML_UPLOAD" not in app.config:
|
||||
app.config['ENABLE_CHAR_XML_UPLOAD'] = False
|
||||
app.config['ENABLE_CHAR_XML_UPLOAD'] = os.getenv(
|
||||
@ -290,6 +301,13 @@ def register_settings(app):
|
||||
app.config['CD_SQLITE_LOCATION']
|
||||
)
|
||||
|
||||
if "CACHE_LOCATION" not in app.config:
|
||||
app.config['CACHE_LOCATION'] = 'app/cache/'
|
||||
app.config['CACHE_LOCATION'] = os.getenv(
|
||||
'CACHE_LOCATION',
|
||||
app.config['CACHE_LOCATION']
|
||||
)
|
||||
|
||||
|
||||
|
||||
def gm_level(gm_level):
|
||||
|
@ -42,7 +42,7 @@ def get_dds_as_png(filename):
|
||||
|
||||
with image.Image(filename=path) as img:
|
||||
img.compression = "no"
|
||||
img.save(filename='app/cache/' + filename.split('.')[0] + '.png')
|
||||
img.save(filename=current_app.config["CACHE_LOCATION"] + filename.split('.')[0] + '.png')
|
||||
|
||||
return send_file(cache)
|
||||
|
||||
@ -90,7 +90,7 @@ def get_icon_lot(id):
|
||||
else:
|
||||
return redirect(url_for('luclient.unknown'))
|
||||
|
||||
cache = f'app/cache/{filename.split(".")[0]}.png'
|
||||
cache = f'{current_app.config["CACHE_LOCATION"]}{filename.split(".")[0]}.png'
|
||||
|
||||
if not os.path.exists(cache):
|
||||
root = f"{current_app.config['CLIENT_LOCATION']}res/"
|
||||
@ -117,7 +117,7 @@ def get_icon_iconid(id):
|
||||
|
||||
filename = filename.replace("..\\", "").replace("\\", "/")
|
||||
|
||||
cache = f'app/cache/{filename.split(".")[0]}.png'
|
||||
cache = f'{current_app.config["CACHE_LOCATION"]}{filename.split(".")[0]}.png'
|
||||
|
||||
if not os.path.exists(cache):
|
||||
root = f"{current_app.config['CLIENT_LOCATION']}res/"
|
||||
@ -174,7 +174,7 @@ def dir_listing(req_path):
|
||||
def unknown():
|
||||
filename = "textures/ui/inventory/unknown.dds"
|
||||
|
||||
cache = f'app/cache/{filename.split(".")[0]}.png'
|
||||
cache = f'{current_app.config["CACHE_LOCATION"]}{filename.split(".")[0]}.png'
|
||||
|
||||
if not os.path.exists(cache):
|
||||
root = f"{current_app.config['CLIENT_LOCATION']}res/"
|
||||
|
@ -460,7 +460,7 @@ def prebuilt(content, file_format, lod):
|
||||
# else we handle getting the files for lddviewer
|
||||
elif file_format in ["obj", "mtl"]:
|
||||
# check to see if the file exists
|
||||
cache = pathlib.Path(f'app/cache/BrickModels/{filename}.lod{lod}.{file_format}')
|
||||
cache = pathlib.Path(f'{current_app.config["CACHE_LOCATION"]}BrickModels/{filename}.lod{lod}.{file_format}')
|
||||
if not cache.is_file():
|
||||
# if not make it an store it for later
|
||||
cache.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
@ -969,8 +969,8 @@ def main(lxf_filename, obj_filename, lod="2"):
|
||||
GEOMETRIEPATH = GEOMETRIEPATH + f"LOD{lod}/"
|
||||
converter = Converter()
|
||||
# print("Found DB folder. Will use this instead of db.lif!")
|
||||
setDBFolderVars(dbfolderlocation=f"{current_app.config['CLIENT_LOCATION']}res/", lod=lod)
|
||||
converter.LoadDBFolder(dbfolderlocation=f"{current_app.config['CLIENT_LOCATION']}res/")
|
||||
setDBFolderVars(dbfolderlocation=f"{current_app.config['CACHE_LOCATION']}", lod=lod)
|
||||
converter.LoadDBFolder(dbfolderlocation=f"{current_app.config['CACHE_LOCATION']}")
|
||||
converter.LoadScene(filename=lxf_filename)
|
||||
converter.Export(filename=obj_filename)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user