Skip to content

Commit

Permalink
fix: remove file entry when trying to delete a non-existant file (xba…
Browse files Browse the repository at this point in the history
…pps#1765)

Co-authored-by: crwxaj <crwxaj>
  • Loading branch information
crwxaj authored Jul 2, 2024
1 parent 9264132 commit e81cfbc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/api/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package api
import (
"context"
"encoding/json"
"errors"
"io/fs"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -347,7 +349,7 @@ func removeFileByFileId(fileId uint) models.Scene {
switch file.Volume.Type {
case "local":
err := os.Remove(filepath.Join(file.Path, file.Filename))
if err == nil {
if err == nil || errors.Is(err, fs.ErrNotExist) {
deleted = true
} else {
log.Errorf("error deleting file: %v", err)
Expand Down

0 comments on commit e81cfbc

Please sign in to comment.