diff --git a/enjoy/src/i18n/en.json b/enjoy/src/i18n/en.json index a0bd9357..b3523f1c 100644 --- a/enjoy/src/i18n/en.json +++ b/enjoy/src/i18n/en.json @@ -667,7 +667,7 @@ "scoreDesc": "Score desc", "scoreAsc": "Score asc", "recordingsDurationDesc": "Recordings duration", - "recordingsCountDesc": "Recordings duration", + "recordingsCountDesc": "Recordings count", "all": "All", "allLanguages": "All languages", "search": "Search", @@ -719,5 +719,9 @@ "textInput": "Text input", "increasePlaybackRate": "Increase playback rate", "descreasePlaybackRate": "Descrease playback rate", - "usage": "Usage" + "usage": "Usage", + "cannotFindSourceFile": "Cannot find source file", + "cleanUp": "Clean up", + "cleanUpConfirmation": "Are you sure to remove resources without source file?", + "cleanedUpSuccessfully": "Cleaned up successfully" } diff --git a/enjoy/src/i18n/zh-CN.json b/enjoy/src/i18n/zh-CN.json index 80f9166b..ccfc2bd4 100644 --- a/enjoy/src/i18n/zh-CN.json +++ b/enjoy/src/i18n/zh-CN.json @@ -719,5 +719,9 @@ "textInput": "文字输入", "increasePlaybackRate": "加快播放速度", "decreasePlaybackRate": "减慢播放速度", - "usage": "使用情况" + "usage": "使用情况", + "cannotFindSourceFile": "无法找到源文件,可能已经被删除", + "cleanUp": "清理", + "cleanUpConfirmation": "您确定要移除所有找不到源文件的资源吗?", + "cleanedUpSuccessfully": "清理成功" } diff --git a/enjoy/src/main/db/handlers/audios-handler.ts b/enjoy/src/main/db/handlers/audios-handler.ts index cfa5969b..6bab5d86 100644 --- a/enjoy/src/main/db/handlers/audios-handler.ts +++ b/enjoy/src/main/db/handlers/audios-handler.ts @@ -168,6 +168,16 @@ class AudiosHandler { return pathToEnjoyUrl(output); } + private async cleanUp() { + const audios = await Audio.findAll(); + + for (const audio of audios) { + if (!audio.src) { + audio.destroy(); + } + } + } + register() { ipcMain.handle("audios-find-all", this.findAll); ipcMain.handle("audios-find-one", this.findOne); @@ -176,6 +186,7 @@ class AudiosHandler { ipcMain.handle("audios-destroy", this.destroy); ipcMain.handle("audios-upload", this.upload); ipcMain.handle("audios-crop", this.crop); + ipcMain.handle("audios-clean-up", this.cleanUp); } } diff --git a/enjoy/src/main/db/handlers/videos-handler.ts b/enjoy/src/main/db/handlers/videos-handler.ts index f32e97df..e66105ad 100644 --- a/enjoy/src/main/db/handlers/videos-handler.ts +++ b/enjoy/src/main/db/handlers/videos-handler.ts @@ -158,6 +158,16 @@ class VideosHandler { return pathToEnjoyUrl(output); } + private async cleanUp() { + const videos = await Video.findAll(); + + for (const video of videos) { + if (!video.src) { + video.destroy(); + } + } + } + register() { ipcMain.handle("videos-find-all", this.findAll); ipcMain.handle("videos-find-one", this.findOne); @@ -166,6 +176,7 @@ class VideosHandler { ipcMain.handle("videos-destroy", this.destroy); ipcMain.handle("videos-upload", this.upload); ipcMain.handle("videos-crop", this.crop); + ipcMain.handle("videos-clean-up", this.cleanUp); } } diff --git a/enjoy/src/main/db/models/audio.ts b/enjoy/src/main/db/models/audio.ts index 27357217..3c769401 100644 --- a/enjoy/src/main/db/models/audio.ts +++ b/enjoy/src/main/db/models/audio.ts @@ -121,11 +121,15 @@ export class Audio extends Model