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 14
14
author_email = "team@micropython.org" ,
15
15
)
16
16
17
- requires ("usb-device" )
17
+ requires ("usb-device" )
18
+ requires ("shutil" )
Original file line number Diff line number Diff line change 7
7
import io
8
8
import errno
9
9
import uctypes
10
+ import shutil
10
11
11
12
from .core import Interface , Buffer , split_bmRequestType
12
13
@@ -963,7 +964,7 @@ def _cmd_get_object(self, params):
963
964
964
965
# Now send the file data in chunks
965
966
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
967
968
968
969
while bytes_sent < filesize :
969
970
# Wait until we can write to the TX buffer
@@ -1026,15 +1027,7 @@ def _cmd_delete_object(self, params):
1026
1027
is_dir = stat [0 ] & 0x4000 # S_IFDIR
1027
1028
1028
1029
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 )
1038
1031
else :
1039
1032
# Delete the file
1040
1033
os .remove (filepath )
You can’t perform that action at this time.
0 commit comments