API: Improve file operation logs

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-01-19 21:11:17 +01:00
parent 6dd55170fe
commit e331fcf43f
2 changed files with 8 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package api
import (
"net/http"
"path"
"time"
"github.com/dustin/go-humanize/english"
@ -382,6 +383,10 @@ func BatchPhotosDelete(router *gin.RouterGroup) {
// Delete photos.
for _, p := range photos {
// Report file deletion.
event.AuditWarn([]string{ClientIP(c), s.UserName, "delete", path.Join(p.PhotoPath, p.PhotoName+"*")})
// Remove all related files from storage.
n, err := photoprism.DeletePhoto(p, true, true)
numFiles += n

View file

@ -68,6 +68,9 @@ func DeleteFile(router *gin.RouterGroup) {
return
}
// Report file deletion.
event.AuditWarn([]string{ClientIP(c), s.UserName, "delete", file.FileName})
// Remove file from storage.
if err = mediaFile.Remove(); err != nil {
log.Errorf("files: %s (delete %s from folder)", err, clean.Log(baseName))