diff --git a/internal/web/ui.go b/internal/web/ui.go index 5d24888..823172d 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -3963,7 +3963,6 @@ func (u *UI) actionFaceGalleryAdd(w http.ResponseWriter, r *http.Request) { return } defer f.Close() - go u.rebuildFaceGallery() io.Copy(f, file) http.Redirect(w, r, "/ui/face-gallery?msg=ok", http.StatusFound) } @@ -4024,10 +4023,8 @@ func (u *UI) actionFaceGalleryDelete(w http.ResponseWriter, r *http.Request) { http.Error(w, "invalid", http.StatusBadRequest) return } - go u.rebuildFaceGallery() if strings.TrimSpace(u.dbPath) != "" { repo := storage.NewFaceGalleryRepo(u.dbPath) repo.DeletePerson(id) - go u.rebuildFaceGallery() } http.Redirect(w, r, "/ui/face-gallery", http.StatusFound) } @@ -4083,8 +4080,13 @@ func (u *UI) actionFaceGalleryImport(w http.ResponseWriter, r *http.Request) { repo := storage.NewFaceGalleryRepo(u.dbPath) for _, files := range r.MultipartForm.File { for _, hdr := range files { - path := strings.ReplaceAll(hdr.Filename, "\\", "/") - parts := strings.Split(path, "/") + cd := hdr.Header.Get("Content-Disposition") + fp := hdr.Filename + if idx := strings.LastIndex(cd, `filename="`); idx >= 0 { + start := idx + len(`filename="`) + if end := strings.IndexByte(cd[start:], '"'); end >= 0 { fp = cd[start : start+end] } + } + parts := strings.Split(strings.ReplaceAll(fp, "\\", "/"), "/") if len(parts) < 2 { continue } personName := strings.TrimSpace(parts[len(parts)-2]) if personName != "" { @@ -4093,7 +4095,6 @@ func (u *UI) actionFaceGalleryImport(w http.ResponseWriter, r *http.Request) { } } } - go u.rebuildFaceGallery() http.Redirect(w, r, fmt.Sprintf("/ui/face-gallery?msg=已导入 %d 张照片", count), http.StatusFound) }