Skip to content

The user does not see a failure when a Move action fails #553

Description

@dhalbert

If the user does a Move which fails (say, due to a read-only filesystem), there is no error indication.

To reproduce: Connect over the BLE workflow with CIRCUITPY mounted over USB, so the filesystem is read-only to CircuitPython, then move any file. The device returns STATUS_ERROR, the client rejects, and the dialog does nothing. Unplugging USB and powering the board separately makes the same move succeed.

Suggested fix details

_handleMoveButton() in js/common/file_dialog.js treats a failed move as a falsy return value:

} else if (!(await this._showBusy(this._fileHelper.move(oldPath, newPath)))) {
    this._showMessage(`Error moving ${oldPath} to ${newPath}. Make sure the file you are moving exists.`);
    errors = true;
}

But move() rejects on failure rather than returning false. processMoveStatus() in @adafruit/ble-file-transfer-js calls this._reject("Unable to move file") when the device answers STATUS_ERROR, and showBusy() is try/finally with no catch, so the rejection propagates out of the handler. _showMessage() never runs, the loop over selected files aborts, and _openFolder(newFolder) never runs.

By contrast, _handleRenameButton(), the next function in the file, already wraps its move() call in try/catch.

To fix, catch the rejection and show its message, which is more specific than the current text:

} else {
    try {
        await this._showBusy(this._fileHelper.move(oldPath, newPath));
    } catch (e) {
        this._showMessage(`Error moving ${oldPath} to ${newPath}: ${e}`);
        errors = true;
    }
}

[originally written by Claude, greatly pruned and edited for clarity by @dhalbert]

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIUser Interface Related IssuesbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions