Fix P2S FTP upload failure - pass skip_session_reuse to ImplicitFTP_TLS (Issue #218)

The fix for A1/P1S FTP uploads (commit 82a6025) was accidentally broken in
commit 9969005 which removed the skip_session_reuse parameter from the
ImplicitFTP_TLS constructor. This caused P2S (and other models in
SKIP_SESSION_REUSE_MODELS) to still use SSL on the data channel, resulting
in "426 Failure reading network stream" errors.

The fix was implemented in commit b96ecfa on test/issue_174 branch but
never merged to main. This cherry-picks that fix.

Also includes:
- Storage diagnostics for debugging upload issues
- Better FTP error logging with specific error codes (553, 550, 552)
- Improved error messages in print scheduler

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
maziggy
2026-02-01 15:15:18 +01:00
co-authored by Claude Opus 4.5
parent 2d445badac
commit 4b2ea2d2c2
4 changed files with 161 additions and 15 deletions
+19 -2
View File
@@ -2538,14 +2538,22 @@ async def reprint_archive(
# Get FTP retry settings
ftp_retry_enabled, ftp_retry_count, ftp_retry_delay, ftp_timeout = await get_ftp_retry_settings()
logger.info(
f"Reprint FTP upload starting: printer={printer.name} ({printer.model}), "
f"ip={printer.ip_address}, file={remote_filename}, local_path={file_path}, "
f"retry_enabled={ftp_retry_enabled}, retry_count={ftp_retry_count}, timeout={ftp_timeout}"
)
# Delete existing file if present (avoids 553 error)
await delete_file_async(
logger.debug(f"Deleting existing file {remote_path} if present...")
delete_result = await delete_file_async(
printer.ip_address,
printer.access_code,
remote_path,
socket_timeout=ftp_timeout,
printer_model=printer.model,
)
logger.debug(f"Delete result: {delete_result}")
if ftp_retry_enabled:
uploaded = await with_ftp_retry(
@@ -2571,7 +2579,16 @@ async def reprint_archive(
)
if not uploaded:
raise HTTPException(500, "Failed to upload file to printer")
logger.error(
f"FTP upload failed for reprint: printer={printer.name}, model={printer.model}, "
f"ip={printer.ip_address}, file={remote_filename}. "
"Check logs above for storage diagnostics and specific error codes."
)
raise HTTPException(
500,
"Failed to upload file to printer. Check if SD card is inserted and properly formatted (FAT32/exFAT). "
"See server logs for detailed diagnostics.",
)
# Register this as an expected print so we don't create a duplicate archive
register_expected_print(printer_id, remote_filename, archive_id)
+19 -2
View File
@@ -1679,14 +1679,22 @@ async def print_library_file(
# Get FTP retry settings
ftp_retry_enabled, ftp_retry_count, ftp_retry_delay, ftp_timeout = await get_ftp_retry_settings()
logger.info(
f"Library print FTP upload starting: printer={printer.name} ({printer.model}), "
f"ip={printer.ip_address}, file={remote_filename}, local_path={file_path}, "
f"retry_enabled={ftp_retry_enabled}, retry_count={ftp_retry_count}, timeout={ftp_timeout}"
)
# Delete existing file if present (avoids 553 error)
await delete_file_async(
logger.debug(f"Deleting existing file {remote_path} if present...")
delete_result = await delete_file_async(
printer.ip_address,
printer.access_code,
remote_path,
socket_timeout=ftp_timeout,
printer_model=printer.model,
)
logger.debug(f"Delete result: {delete_result}")
# Upload file to printer
if ftp_retry_enabled:
@@ -1713,7 +1721,16 @@ async def print_library_file(
)
if not uploaded:
raise HTTPException(status_code=500, detail="Failed to upload file to printer")
logger.error(
f"FTP upload failed for library print: printer={printer.name}, model={printer.model}, "
f"ip={printer.ip_address}, file={remote_filename}. "
"Check logs above for storage diagnostics and specific error codes."
)
raise HTTPException(
status_code=500,
detail="Failed to upload file to printer. Check if SD card is inserted and properly formatted (FAT32/exFAT). "
"See server logs for detailed diagnostics.",
)
# Register this as an expected print so we don't create a duplicate archive
register_expected_print(printer_id, remote_filename, archive.id)