refactor: use fullFilename helper in both places
This commit is contained in:
parent
003d50bcc6
commit
1f6d64ce0b
@ -4041,15 +4041,7 @@ func (u *UI) actionFaceGalleryImport(w http.ResponseWriter, r *http.Request) {
|
||||
count := 0
|
||||
for _, files := range r.MultipartForm.File {
|
||||
for _, hdr := range files {
|
||||
// Go 1.20+ sanitizes hdr.Filename to basename only, parse raw Content-Disposition for full path
|
||||
cd := hdr.Header.Get("Content-Disposition")
|
||||
fullPath := hdr.Filename
|
||||
if idx := strings.LastIndex(cd, `filename="`); idx >= 0 {
|
||||
start := idx + len(`filename="`)
|
||||
if end := strings.IndexByte(cd[start:], '"'); end >= 0 {
|
||||
fullPath = cd[start : start+end]
|
||||
}
|
||||
}
|
||||
fullPath := fullFilename(hdr)
|
||||
parts := strings.Split(strings.ReplaceAll(fullPath, "\\", "/"), "/")
|
||||
if len(parts) < 2 {
|
||||
continue
|
||||
@ -4082,12 +4074,7 @@ 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 {
|
||||
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] }
|
||||
}
|
||||
fp := fullFilename(hdr)
|
||||
parts := strings.Split(strings.ReplaceAll(fp, "\\", "/"), "/")
|
||||
if len(parts) < 2 { continue }
|
||||
personName := strings.TrimSpace(parts[len(parts)-2])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user