maotoumao/MusicFree · warning

${t("panel.musicItemOptions.deleteFailed")} ${e?.message ??

Error message

${t("panel.musicItemOptions.deleteFailed")} ${e?.message ?? e}

What it means

Toast shown when deleting a locally-downloaded music item fails. In the delete-confirm dialog's onOk, LocalMusicSheet.removeMusic(musicItem, true) is awaited; a rejection surfaces as a warning composed of the localized 'deleteFailed' text plus the exception message.

Source

Thrown at src/components/panels/types/musicItemOptions.tsx:169

                }
                Toast.success(t("toast.deleteSuccess"));
                hidePanel();
            },
        },
        {
            icon: "trash-outline",
            title: t("panel.musicItemOptions.deleteLocalDownload"),
            show: !!downloaded,
            onPress: () => {
                showDialog("SimpleDialog", {
                    title: t("panel.musicItemOptions.deleteLocalDownload"),
                    content: t("panel.musicItemOptions.deleteLocalDownloadConfirm"),
                    async onOk() {
                        try {
                            await LocalMusicSheet.removeMusic(musicItem, true);
                            Toast.success(t("toast.deleteSuccess"));
                        } catch (e: any) {
                            Toast.warn(`${t("panel.musicItemOptions.deleteFailed")} ${e?.message ?? e}`);
                        }
                    },
                });
                hidePanel();
            },
        },
        {
            icon: "chat-bubble-oval-left-ellipsis",
            title: t("panel.musicItemOptions.readComment"),
            show: !!pluginManager.getByMedia(musicItem)?.supportedMethods.has("getMusicComments"),
            onPress: () => {
                if (!musicItem) {
                    return;
                }
                showPanel("MusicComment", {
                    musicItem: musicItem,
                });
            },

View on GitHub (pinned to d118b18b3d)

Solutions

  1. Read the appended e?.message in the toast to identify the cause
  2. Refresh the local music sheet and retry the delete
  3. Check storage permissions and that the file path still exists
  4. Clear/rebuild the local download cache if metadata is stale

Example fix

// before
await LocalMusicSheet.removeMusic(musicItem, true);
// after
await LocalMusicSheet.removeMusic(musicItem, true).catch(e => {
    console.warn('removeMusic failed', e);
    throw e;
});
Defensive patterns

Strategy: try-catch

Validate before calling

if (!musicItem?.$localPath) {
    Toast.warn('该歌曲没有本地下载文件');
    return;
}

Type guard

function isLocalDownloaded(m: any): boolean {
    return typeof m?.$localPath === 'string' && m.$localPath.length > 0;
}

Try / catch

try {
    await LocalMusicSheet.removeMusic(musicItem, true);
    Toast.success(t('toast.deleteSuccess'));
} catch (e: any) {
    Toast.warn(`${t('panel.musicItemOptions.deleteFailed')} ${e?.message ?? e}`);
}

Prevention

When it happens

Trigger: Confirming deletion of a local download when removeMusic throws — the underlying file is locked/missing, the media library fails to remove the row, or musicItem no longer exists in the local sheet.

Common situations: File already removed by another app or a previous delete; storage permission revoked; sync race where the item was removed concurrently; corrupt download cache.

Related errors


AI-assisted analysis of maotoumao/MusicFree@d118b18b3d (2026-08-30). Data as JSON: /api/errors/8e59b662b80d0503. Report an issue: GitHub.