file_manager: make the thumbs directory hidden
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
23dd001a9b
commit
ecbf663b18
|
@ -441,7 +441,7 @@ class FileManager:
|
||||||
def _unzip_ufp(self, ufp_path, dest_path):
|
def _unzip_ufp(self, ufp_path, dest_path):
|
||||||
thumb_name = os.path.splitext(
|
thumb_name = os.path.splitext(
|
||||||
os.path.basename(dest_path))[0] + ".png"
|
os.path.basename(dest_path))[0] + ".png"
|
||||||
dest_thumb_dir = os.path.join(os.path.dirname(dest_path), "thumbs")
|
dest_thumb_dir = os.path.join(os.path.dirname(dest_path), ".thumbs")
|
||||||
dest_thumb_path = os.path.join(dest_thumb_dir, thumb_name)
|
dest_thumb_path = os.path.join(dest_thumb_dir, thumb_name)
|
||||||
try:
|
try:
|
||||||
with tempfile.TemporaryDirectory() as tmp_dir_name:
|
with tempfile.TemporaryDirectory() as tmp_dir_name:
|
||||||
|
@ -929,6 +929,7 @@ METADATA_VERSION = 3
|
||||||
class MetadataStorage:
|
class MetadataStorage:
|
||||||
def __init__(self, server, gc_path, database):
|
def __init__(self, server, gc_path, database):
|
||||||
self.server = server
|
self.server = server
|
||||||
|
self.gc_path = gc_path
|
||||||
database.register_local_namespace(METADATA_NAMESPACE)
|
database.register_local_namespace(METADATA_NAMESPACE)
|
||||||
self.mddb = database.wrap_namespace(
|
self.mddb = database.wrap_namespace(
|
||||||
METADATA_NAMESPACE, parse_keys=False)
|
METADATA_NAMESPACE, parse_keys=False)
|
||||||
|
@ -936,14 +937,14 @@ class MetadataStorage:
|
||||||
"moonraker", "file_manager.metadata_version", 0)
|
"moonraker", "file_manager.metadata_version", 0)
|
||||||
if version != METADATA_VERSION:
|
if version != METADATA_VERSION:
|
||||||
# Clear existing metadata when version is bumped
|
# Clear existing metadata when version is bumped
|
||||||
self.mddb.clear()
|
for fname in self.mddb.keys():
|
||||||
|
self.remove_file_metadata(fname)
|
||||||
database.insert_item(
|
database.insert_item(
|
||||||
"moonraker", "file_manager.metadata_version",
|
"moonraker", "file_manager.metadata_version",
|
||||||
METADATA_VERSION)
|
METADATA_VERSION)
|
||||||
self.pending_requests = {}
|
self.pending_requests = {}
|
||||||
self.events = {}
|
self.events = {}
|
||||||
self.busy = False
|
self.busy = False
|
||||||
self.gc_path = gc_path
|
|
||||||
if self.gc_path:
|
if self.gc_path:
|
||||||
# Check for removed gcode files while moonraker was shutdown
|
# Check for removed gcode files while moonraker was shutdown
|
||||||
for fname in list(self.mddb.keys()):
|
for fname in list(self.mddb.keys()):
|
||||||
|
|
|
@ -213,7 +213,7 @@ class PrusaSlicer(BaseSlicer):
|
||||||
r"; thumbnail begin[;/\+=\w\s]+?; thumbnail end", self.header_data)
|
r"; thumbnail begin[;/\+=\w\s]+?; thumbnail end", self.header_data)
|
||||||
if not thumb_matches:
|
if not thumb_matches:
|
||||||
return None
|
return None
|
||||||
thumb_dir = os.path.join(os.path.dirname(self.path), "thumbs")
|
thumb_dir = os.path.join(os.path.dirname(self.path), ".thumbs")
|
||||||
if not os.path.exists(thumb_dir):
|
if not os.path.exists(thumb_dir):
|
||||||
try:
|
try:
|
||||||
os.mkdir(thumb_dir)
|
os.mkdir(thumb_dir)
|
||||||
|
@ -238,7 +238,7 @@ class PrusaSlicer(BaseSlicer):
|
||||||
continue
|
continue
|
||||||
thumb_name = f"{thumb_base}-{info[0]}x{info[1]}.png"
|
thumb_name = f"{thumb_base}-{info[0]}x{info[1]}.png"
|
||||||
thumb_path = os.path.join(thumb_dir, thumb_name)
|
thumb_path = os.path.join(thumb_dir, thumb_name)
|
||||||
rel_thumb_path = os.path.join("thumbs", thumb_name)
|
rel_thumb_path = os.path.join(".thumbs", thumb_name)
|
||||||
with open(thumb_path, "wb") as f:
|
with open(thumb_path, "wb") as f:
|
||||||
f.write(base64.b64decode(data.encode()))
|
f.write(base64.b64decode(data.encode()))
|
||||||
parsed_matches.append({
|
parsed_matches.append({
|
||||||
|
@ -355,11 +355,11 @@ class Cura(PrusaSlicer):
|
||||||
if thumbs is not None:
|
if thumbs is not None:
|
||||||
return thumbs
|
return thumbs
|
||||||
# Check for thumbnails extracted from the ufp
|
# Check for thumbnails extracted from the ufp
|
||||||
thumb_dir = os.path.join(os.path.dirname(self.path), "thumbs")
|
thumb_dir = os.path.join(os.path.dirname(self.path), ".thumbs")
|
||||||
thumb_base = os.path.splitext(os.path.basename(self.path))[0]
|
thumb_base = os.path.splitext(os.path.basename(self.path))[0]
|
||||||
thumb_path = os.path.join(thumb_dir, f"{thumb_base}.png")
|
thumb_path = os.path.join(thumb_dir, f"{thumb_base}.png")
|
||||||
rel_path_full = os.path.join("thumbs", f"{thumb_base}.png")
|
rel_path_full = os.path.join(".thumbs", f"{thumb_base}.png")
|
||||||
rel_path_small = os.path.join("thumbs", f"{thumb_base}-32x32.png")
|
rel_path_small = os.path.join(".thumbs", f"{thumb_base}-32x32.png")
|
||||||
thumb_path_small = os.path.join(thumb_dir, f"{thumb_base}-32x32.png")
|
thumb_path_small = os.path.join(thumb_dir, f"{thumb_base}-32x32.png")
|
||||||
if not os.path.isfile(thumb_path):
|
if not os.path.isfile(thumb_path):
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue