fix: register persons in app.db, async rebuild face gallery
This commit is contained in:
parent
d4fe5c8459
commit
71d789e69a
@ -3963,7 +3963,7 @@ func (u *UI) actionFaceGalleryAdd(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
u.rebuildFaceGallery()
|
||||
go u.rebuildFaceGallery()
|
||||
io.Copy(f, file)
|
||||
http.Redirect(w, r, "/ui/face-gallery?msg=ok", http.StatusFound)
|
||||
}
|
||||
@ -4024,10 +4024,10 @@ func (u *UI) actionFaceGalleryDelete(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "invalid", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
u.rebuildFaceGallery()
|
||||
go u.rebuildFaceGallery()
|
||||
if strings.TrimSpace(u.dbPath) != "" { repo := storage.NewFaceGalleryRepo(u.dbPath)
|
||||
repo.DeletePerson(id)
|
||||
u.rebuildFaceGallery()
|
||||
go u.rebuildFaceGallery()
|
||||
}
|
||||
http.Redirect(w, r, "/ui/face-gallery", http.StatusFound)
|
||||
}
|
||||
@ -4075,10 +4075,25 @@ func (u *UI) actionFaceGalleryImport(w http.ResponseWriter, r *http.Request) {
|
||||
io.Copy(f, file)
|
||||
f.Close()
|
||||
file.Close()
|
||||
u.rebuildFaceGallery()
|
||||
count++
|
||||
}
|
||||
}
|
||||
// Register all persons in app DB and rebuild
|
||||
if strings.TrimSpace(u.dbPath) != "" {
|
||||
repo := storage.NewFaceGalleryRepo(u.dbPath)
|
||||
for _, files := range r.MultipartForm.File {
|
||||
for _, hdr := range files {
|
||||
path := strings.ReplaceAll(hdr.Filename, "\\", "/")
|
||||
parts := strings.Split(path, "/")
|
||||
if len(parts) < 2 { continue }
|
||||
personName := strings.TrimSpace(parts[len(parts)-2])
|
||||
if personName != "" {
|
||||
repo.FindOrCreatePerson(personName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
go u.rebuildFaceGallery()
|
||||
http.Redirect(w, r, fmt.Sprintf("/ui/face-gallery?msg=已导入 %d 张照片", count), http.StatusFound)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user