-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix cache file list issues optimize file listing to only update when retrieving file list and not while selecting or deleting a file don't remove intermediary file on local storage
- Loading branch information
Showing
5 changed files
with
91 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ def __init__( | |
self._sdPrintStarting = False | ||
self._sdPrintingSemaphore = threading.Event() | ||
self._sdPrintingPausedSemaphore = threading.Event() | ||
self._sdFileListCache = {} | ||
self._selectedSdFile = None | ||
self._selectedSdFileSize = 0 | ||
self._selectedSdFilePos = 0 | ||
|
@@ -79,6 +80,7 @@ def __init__( | |
self._busy_loop = None | ||
|
||
|
||
|
||
import logging | ||
|
||
self._logger = logging.getLogger( | ||
|
@@ -172,8 +174,12 @@ def new_update(self, event_type): | |
self._sdPrintStarting = False | ||
if not self._sdPrinting: | ||
filename = print_job.get("subtask_name") | ||
if filename[-4:].lower() != ".3mf": | ||
filename = print_job.get("gcode_file") | ||
if not self._sdFileListCache.get(filename.lower()): | ||
if self._sdFileListCache.get(f"{filename.lower()}.3mf"): | ||
filename = f"{filename.lower()}.3mf" | ||
elif self._sdFileListCache.get(f"{filename.lower()}.gcode.3mf"): | ||
filename = f"{filename.lower()}.gcode.3mf" | ||
|
||
self._selectSdFile(filename) | ||
self._startSdPrint(from_printer=True) | ||
|
||
|
@@ -670,11 +676,11 @@ def _mappedSdList(self) -> Dict[str, Dict[str, Any]]: | |
|
||
for entry in filelistcache: | ||
if entry.startswith("/"): | ||
filename = entry[1:] | ||
filename = entry[1:].replace("cache/", "") | ||
else: | ||
filename = entry | ||
filesize = ftp.ftps_session.size("cache/"+entry) | ||
date_str = ftp.ftps_session.sendcmd(f"MDTM cache/{entry}").replace("213 ", "") | ||
filename = entry.replace("cache/", "") | ||
filesize = ftp.ftps_session.size(entry) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jneilliii
Author
Owner
|
||
date_str = ftp.ftps_session.sendcmd(f"MDTM {entry}").replace("213 ", "") | ||
filedate = datetime.datetime.strptime(date_str, "%Y%m%d%H%M%S").replace(tzinfo=datetime.timezone.utc).timestamp() | ||
dosname = get_dos_filename(filename, existing_filenames=list(result.keys())).lower() | ||
data = { | ||
|
@@ -690,15 +696,14 @@ def _mappedSdList(self) -> Dict[str, Dict[str, Any]]: | |
return result | ||
|
||
def _getSdFileData(self, filename: str) -> Optional[Dict[str, Any]]: | ||
files = self._mappedSdList() | ||
data = files.get(filename.lower()) | ||
data = self._sdFileListCache.get(filename.lower()) | ||
if isinstance(data, str): | ||
data = files.get(data.lower()) | ||
data = self._sdFileListCache.get(data.lower()) | ||
return data | ||
|
||
def _getSdFiles(self) -> List[Dict[str, Any]]: | ||
files = self._mappedSdList() | ||
return [x for x in files.values() if isinstance(x, dict)] | ||
self._sdFileListCache = self._mappedSdList() | ||
return [x for x in self._sdFileListCache.values() if isinstance(x, dict)] | ||
|
||
def _selectSdFile(self, filename: str, check_already_open: bool = False) -> None: | ||
if filename.startswith("/"): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filesize and date_str broken after removing "cache/" from path.