File tree Expand file tree Collapse file tree 2 files changed +5
-11
lines changed
micropython/usb/usb-device-mtp Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change 1414 author_email = "team@micropython.org" ,
1515)
1616
17- requires ("usb-device" )
17+ requires ("usb-device" )
18+ requires ("shutil" )
Original file line number Diff line number Diff line change 77import io
88import errno
99import uctypes
10+ import shutil
1011
1112from .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 )
You can’t perform that action at this time.
0 commit comments