Harden drag/drop path handling and user feedback

This commit is contained in:
Stu 2025-12-04 07:08:12 -05:00
parent ffca39811a
commit b7b5788938

15
main.go
View File

@ -3805,6 +3805,10 @@ func (s *appState) handleDropPlayer(items []fyne.URI) {
var videoPaths []string
for _, uri := range items {
path := uriPath(uri)
if path == "" {
logging.Debug(logging.CatModule, "drop received empty path; uri=%v", uri)
continue
}
logging.Debug(logging.CatModule, "drop received path=%s", path)
if info, err := os.Stat(path); err == nil && info.IsDir() {
@ -3817,6 +3821,9 @@ func (s *appState) handleDropPlayer(items []fyne.URI) {
if len(videoPaths) == 0 {
logging.Debug(logging.CatUI, "no valid video files in dropped items")
fyne.Do(func() {
dialog.ShowInformation("No videos found", "Drop a video file or a folder containing videos.", s.window)
})
return
}
@ -3837,6 +3844,14 @@ func uriPath(u fyne.URI) string {
return p
}
raw := u.String()
if raw == "" {
return ""
}
if parsed, err := url.Parse(raw); err == nil {
if parsed.Scheme == "file" {
return parsed.Path
}
}
if strings.HasPrefix(raw, "file://") {
raw = strings.TrimPrefix(raw, "file://")
}