file_manager: add method to retreive the metadata storage object
This allows other components to synchronously access and update metadata if necessary. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
0dd10ce116
commit
9e57db0611
|
@ -12,6 +12,7 @@ import logging
|
|||
import json
|
||||
import tempfile
|
||||
import asyncio
|
||||
from copy import deepcopy
|
||||
from inotify_simple import INotify
|
||||
from inotify_simple import flags as iFlags
|
||||
|
||||
|
@ -198,6 +199,9 @@ class FileManager:
|
|||
return ""
|
||||
return os.path.relpath(full_path, start=root_dir)
|
||||
|
||||
def get_metadata_storage(self) -> MetadataStorage:
|
||||
return self.gcode_metadata
|
||||
|
||||
def check_file_exists(self, root: str, filename: str) -> bool:
|
||||
root_dir = self.file_paths.get(root, "")
|
||||
file_path = os.path.join(root_dir, filename)
|
||||
|
@ -1500,7 +1504,12 @@ class MetadataStorage:
|
|||
key: str,
|
||||
default: _T = None
|
||||
) -> Union[_T, Dict[str, Any]]:
|
||||
return self.metadata.get(key, default)
|
||||
return deepcopy(self.metadata.get(key, default))
|
||||
|
||||
def insert(self, key: str, value: Dict[str, Any]) -> None:
|
||||
val = deepcopy(value)
|
||||
self.metadata[key] = val
|
||||
self.mddb[key] = val
|
||||
|
||||
def _has_valid_data(self,
|
||||
fname: str,
|
||||
|
|
Loading…
Reference in New Issue