Skip to content

Commit

Permalink
4.1.2 (#58)
Browse files Browse the repository at this point in the history
fix issue where restarting the same file doesn't work with auto start disabled
  • Loading branch information
jneilliii authored Sep 29, 2023
1 parent 7026e72 commit 1a4b890
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions octoprint_simplyprint/websocket/simplyprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,28 +584,30 @@ def _process_demand(self, demand: str, args: Dict[str, Any]) -> None:
self._logger.debug(f"Invalid url in message")
return
file_id: Optional[str] = args.get("file_id")
if self.last_downloaded_file != file_id or file_id is None:
file_name: Optional[str] = args.get("file_name")
start = bool(args.get("auto_start", 0))

if file_id != self.last_downloaded_file or self.file_manager.file_exists(FileDestinations.LOCAL, f"SimplyPrint/{file_name}") is False:
self.last_downloaded_file = file_id
skip_download = False
self._logger.debug(f"downloading file \"{file_name}\"")
self.file_handler.download_file(url, start)
else:
skip_download = True
start = bool(args.get("auto_start", 0))
self.file_handler.pending_file = f"SimplyPrint/{file_name}"
if start:
self._logger.debug(f"starting locally stored file \"{file_name}\"")
self._process_demand("start_print", {})
else:
self._logger.debug(f"letting SP know \"{file_name}\" is ready")
self.send_sp("file_progress", {"state": "ready"})

if self.file_manager.folder_exists(FileDestinations.LOCAL, "SimplyPrint"):
files = self.file_manager.list_files(FileDestinations.LOCAL, "SimplyPrint")
for file, data in files["local"].items():
if skip_download is False:
self._logger.debug(f"deleting locally stored file \"{file}\"")
if data["path"] != f"SimplyPrint/{file_name}":
self._logger.debug(f"purging \"{file}\"")
self.file_manager.remove_file(FileDestinations.LOCAL, data["path"])
else:
self._logger.debug(f"selecting locally stored file \"{file}\"")
self.file_handler.pending_file = data["path"]
if start:
self._logger.debug(f"starting locally stored file \"{file}\"")
self._process_demand("start_print", {})
return

self.file_handler.download_file(url, start)
self._logger.debug(f"not purging {file}")

elif demand == "start_print":
def _on_start_finished(fut: asyncio.Future):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
# Remember to bump the version in octoprint_simplyprint/__init__.py as well
plugin_version = "4.1.1"
plugin_version = "4.1.2"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 1a4b890

Please sign in to comment.