Skip to content

Commit 8d73909

Browse files
committed
Fix BLE autoreload
The trigger was happening when reload was suspended and therefore ignored. Now, manage reload in one place in the file. This may trigger reloads on BLE command error but that should be rare. Fixes #6258
1 parent e0827eb commit 8d73909

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

supervisor/shared/bluetooth/file_transfer.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ STATIC uint8_t _process_write(const uint8_t *raw_buf, size_t command_len) {
325325
if (chunk_size == 0) {
326326
// Don't reload until everything is written out of the packet buffer.
327327
common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer);
328-
autoreload_trigger();
329328
return ANY_COMMAND;
330329
}
331330

@@ -382,7 +381,6 @@ STATIC uint8_t _process_write_data(const uint8_t *raw_buf, size_t command_len) {
382381
#endif
383382
// Don't reload until everything is written out of the packet buffer.
384383
common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer);
385-
autoreload_trigger();
386384
return ANY_COMMAND;
387385
}
388386
return WRITE_DATA;
@@ -463,7 +461,6 @@ STATIC uint8_t _process_delete(const uint8_t *raw_buf, size_t command_len) {
463461
if (result == FR_OK) {
464462
// Don't reload until everything is written out of the packet buffer.
465463
common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer);
466-
autoreload_trigger();
467464
}
468465
return ANY_COMMAND;
469466
}
@@ -517,7 +514,6 @@ STATIC uint8_t _process_mkdir(const uint8_t *raw_buf, size_t command_len) {
517514
if (result == FR_OK) {
518515
// Don't reload until everything is written out of the packet buffer.
519516
common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer);
520-
autoreload_trigger();
521517
}
522518
return ANY_COMMAND;
523519
}
@@ -664,7 +660,6 @@ STATIC uint8_t _process_move(const uint8_t *raw_buf, size_t command_len) {
664660
if (result == FR_OK) {
665661
// Don't reload until everything is written out of the packet buffer.
666662
common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer);
667-
autoreload_trigger();
668663
}
669664
return ANY_COMMAND;
670665
}
@@ -740,6 +735,14 @@ void supervisor_bluetooth_file_transfer_background(void) {
740735
}
741736
if (next_command == ANY_COMMAND) {
742737
autoreload_resume(AUTORELOAD_SUSPEND_BLE);
738+
// Trigger a reload if the command may have mutated the file system.
739+
if (current_state == WRITE ||
740+
current_state == WRITE_DATA ||
741+
current_state == DELETE ||
742+
current_state == MKDIR ||
743+
current_state == MOVE) {
744+
autoreload_trigger();
745+
}
743746
}
744747
}
745748
running = false;

0 commit comments

Comments
 (0)