From 0d5f2e7de0414ca52eb30056c8f2d4d73050c66b Mon Sep 17 00:00:00 2001 From: yanghao05 Date: Sat, 29 Mar 2025 18:18:06 +0800 Subject: [PATCH] fix: issues --- backend/app/service/commands/compress.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/app/service/commands/compress.go b/backend/app/service/commands/compress.go index bdf62da..c2aeec7 100644 --- a/backend/app/service/commands/compress.go +++ b/backend/app/service/commands/compress.go @@ -193,18 +193,19 @@ func calculateMD5(filePath string) (string, error) { // doCompress compresses the video file func doCompress(srcPath, dstPath string) error { // get file ext - ext := filepath.Ext(srcPath) + ext := strings.ToLower(filepath.Ext(srcPath)) if ext == "" { return errors.New("file has no extension") } // check if the file is a .mp3 - if ext == ".mp3" { + if strings.EqualFold(ext, ".mp3") { return compressAudio(srcPath, dstPath) } // check if the file is a video - if ext != ".mp4" && ext != ".avi" && ext != ".mkv" { + videoExts := []string{".mp4", ".avi", ".mkv"} + if !lo.Contains(videoExts, ext) { return errors.New("file is not a video") }