file_manager: allow inotify to exclusively handle gcode metadata and ufp files
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
c2871d94ed
commit
48607f8ab3
|
@ -296,23 +296,10 @@ class FileManager:
|
||||||
ext = os.path.splitext(fname)[-1].lower()
|
ext = os.path.splitext(fname)[-1].lower()
|
||||||
gc_path = self.file_paths.get('gcodes', None)
|
gc_path = self.file_paths.get('gcodes', None)
|
||||||
if gc_path is not None and full_path.startswith(gc_path) and \
|
if gc_path is not None and full_path.startswith(gc_path) and \
|
||||||
ext in VALID_GCODE_EXTS:
|
ext in VALID_GCODE_EXTS and is_extended:
|
||||||
if ext == ".ufp":
|
|
||||||
try:
|
|
||||||
full_path = self.process_ufp_from_refresh(
|
|
||||||
full_path)
|
|
||||||
except Exception:
|
|
||||||
logging.exception("Error processing ufp file")
|
|
||||||
continue
|
|
||||||
path_info = self.get_path_info(full_path)
|
|
||||||
path_info['filename'] = os.path.split(full_path)[-1]
|
|
||||||
rel_path = os.path.relpath(full_path, start=gc_path)
|
rel_path = os.path.relpath(full_path, start=gc_path)
|
||||||
self.gcode_metadata.parse_metadata(
|
metadata = self.gcode_metadata.get(rel_path, {})
|
||||||
rel_path, path_info['size'], path_info['modified'],
|
path_info.update(metadata)
|
||||||
notify=True)
|
|
||||||
metadata = self.gcode_metadata.get(rel_path, None)
|
|
||||||
if metadata is not None and is_extended:
|
|
||||||
path_info.update(metadata)
|
|
||||||
flist['files'].append(path_info)
|
flist['files'].append(path_info)
|
||||||
usage = shutil.disk_usage(path)
|
usage = shutil.disk_usage(path)
|
||||||
flist['disk_usage'] = usage._asdict()
|
flist['disk_usage'] = usage._asdict()
|
||||||
|
@ -511,20 +498,11 @@ class FileManager:
|
||||||
if root == 'gcodes' and ext not in VALID_GCODE_EXTS:
|
if root == 'gcodes' and ext not in VALID_GCODE_EXTS:
|
||||||
continue
|
continue
|
||||||
full_path = os.path.join(dir_path, name)
|
full_path = os.path.join(dir_path, name)
|
||||||
if root == 'gcodes' and ext == ".ufp":
|
|
||||||
try:
|
|
||||||
full_path = self.process_ufp_from_refresh(full_path)
|
|
||||||
except Exception:
|
|
||||||
logging.exception("Error processing ufp file")
|
|
||||||
continue
|
|
||||||
if not os.path.exists(full_path):
|
if not os.path.exists(full_path):
|
||||||
continue
|
continue
|
||||||
fname = full_path[len(path) + 1:]
|
fname = full_path[len(path) + 1:]
|
||||||
finfo = self.get_path_info(full_path)
|
finfo = self.get_path_info(full_path)
|
||||||
filelist[fname] = finfo
|
filelist[fname] = finfo
|
||||||
if root == 'gcodes':
|
|
||||||
self.gcode_metadata.parse_metadata(
|
|
||||||
fname, finfo['size'], finfo['modified'])
|
|
||||||
if list_format:
|
if list_format:
|
||||||
flist = []
|
flist = []
|
||||||
for fname in sorted(filelist, key=str.lower):
|
for fname in sorted(filelist, key=str.lower):
|
||||||
|
|
Loading…
Reference in New Issue