{"record":{"id":"8e59b662b80d0503","repo":"maotoumao/MusicFree","slug":"t-panel-musicitemoptions-deletefailed-e-m","errorCode":null,"errorMessage":"${t(\"panel.musicItemOptions.deleteFailed\")} ${e?.message ?? e}","messagePattern":"\\$\\{t\\(\"panel\\.musicItemOptions\\.deleteFailed\"\\)\\} \\$\\{e\\?\\.message \\?\\? e\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/components/panels/types/musicItemOptions.tsx","lineNumber":169,"sourceCode":"                }\r\n                Toast.success(t(\"toast.deleteSuccess\"));\r\n                hidePanel();\r\n            },\r\n        },\r\n        {\r\n            icon: \"trash-outline\",\r\n            title: t(\"panel.musicItemOptions.deleteLocalDownload\"),\r\n            show: !!downloaded,\r\n            onPress: () => {\r\n                showDialog(\"SimpleDialog\", {\r\n                    title: t(\"panel.musicItemOptions.deleteLocalDownload\"),\r\n                    content: t(\"panel.musicItemOptions.deleteLocalDownloadConfirm\"),\r\n                    async onOk() {\r\n                        try {\r\n                            await LocalMusicSheet.removeMusic(musicItem, true);\r\n                            Toast.success(t(\"toast.deleteSuccess\"));\r\n                        } catch (e: any) {\r\n                            Toast.warn(`${t(\"panel.musicItemOptions.deleteFailed\")} ${e?.message ?? e}`);\r\n                        }\r\n                    },\r\n                });\r\n                hidePanel();\r\n            },\r\n        },\r\n        {\r\n            icon: \"chat-bubble-oval-left-ellipsis\",\r\n            title: t(\"panel.musicItemOptions.readComment\"),\r\n            show: !!pluginManager.getByMedia(musicItem)?.supportedMethods.has(\"getMusicComments\"),\r\n            onPress: () => {\r\n                if (!musicItem) {\r\n                    return;\r\n                }\r\n                showPanel(\"MusicComment\", {\r\n                    musicItem: musicItem,\r\n                });\r\n            },\r","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/components/panels/types/musicItemOptions.tsx#L151-L187","documentation":"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.","triggerScenarios":"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.","commonSituations":"File already removed by another app or a previous delete; storage permission revoked; sync race where the item was removed concurrently; corrupt download cache.","solutions":["Read the appended e?.message in the toast to identify the cause","Refresh the local music sheet and retry the delete","Check storage permissions and that the file path still exists","Clear/rebuild the local download cache if metadata is stale"],"exampleFix":"// before\nawait LocalMusicSheet.removeMusic(musicItem, true);\n// after\nawait LocalMusicSheet.removeMusic(musicItem, true).catch(e => {\n    console.warn('removeMusic failed', e);\n    throw e;\n});","handlingStrategy":"try-catch","validationCode":"if (!musicItem?.$localPath) {\n    Toast.warn('该歌曲没有本地下载文件');\n    return;\n}","typeGuard":"function isLocalDownloaded(m: any): boolean {\n    return typeof m?.$localPath === 'string' && m.$localPath.length > 0;\n}","tryCatchPattern":"try {\n    await LocalMusicSheet.removeMusic(musicItem, true);\n    Toast.success(t('toast.deleteSuccess'));\n} catch (e: any) {\n    Toast.warn(`${t('panel.musicItemOptions.deleteFailed')} ${e?.message ?? e}`);\n}","preventionTips":["Confirm the file exists before deleting (fs.exists)","Refresh the local sheet to drop stale entries","Keep storage permissions valid"],"tags":["file-deletion","local-music"],"backgroundTag":"local-music-delete-failed","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}