tools/mpremote: Fix UnboundLocalError in Transport.fs_writefile().

The variable `written` was being used before it was defined in the
`fs_writefile()` method of the Transport class.  This was causing an
`UnboundLocalError` to be raised when the `progress_callback` was not
provided.

Fixes issue #16084.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
This commit is contained in:
Glenn Moloney 2024-10-26 15:19:54 +11:00 committed by Damien George
parent f212bbe837
commit 5c7ac55232

View File

@ -151,9 +151,9 @@ class Transport:
while data:
chunk = data[:chunk_size]
self.exec("w(" + repr(chunk) + ")")
written += len(chunk)
data = data[len(chunk) :]
if progress_callback:
written += len(chunk)
progress_callback(written, src_size)
self.exec("f.close()")
except TransportExecError as e: