Skip to content

Commit c551de3

Browse files
committed
Fixes
1 parent 95d46fa commit c551de3

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

micropython/usb/usb-device-mtp/manifest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
author_email="team@micropython.org",
1515
)
1616

17-
requires("usb-device")
17+
requires("usb-device")
18+
requires("shutil")

micropython/usb/usb-device-mtp/usb/device/mtp.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io
88
import errno
99
import uctypes
10+
import shutil
1011

1112
from .core import Interface, Buffer, split_bmRequestType
1213

@@ -963,7 +964,7 @@ def _cmd_get_object(self, params):
963964

964965
# Now send the file data in chunks
965966
bytes_sent = 0
966-
chunk_size = min(4096, self._tx.max_write()) # Adjust chunk size based on buffer capacity
967+
chunk_size = min(4096, self._tx.writable()) # Adjust chunk size based on buffer capacity
967968

968969
while bytes_sent < filesize:
969970
# Wait until we can write to the TX buffer
@@ -1026,15 +1027,7 @@ def _cmd_delete_object(self, params):
10261027
is_dir = stat[0] & 0x4000 # S_IFDIR
10271028

10281029
if is_dir:
1029-
# Only delete empty directories
1030-
try:
1031-
os.rmdir(filepath)
1032-
except OSError as e:
1033-
if e.errno == errno.ENOTEMPTY:
1034-
self._send_response(_MTP_RESPONSE_PARTIAL_DELETION)
1035-
return
1036-
else:
1037-
raise
1030+
shutil.rmtree(filepath)
10381031
else:
10391032
# Delete the file
10401033
os.remove(filepath)

0 commit comments

Comments
 (0)