fyne icon indicating copy to clipboard operation
fyne copied to clipboard

func (f *fileDialog) setLocation(dir fyne.URI) error { does not work with non "file" repository

Open brucealthompson opened this issue 4 months ago • 3 comments

Checklist

  • [X] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • [X] This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

There is "file" respository specific code in fyne.io\fyne\[email protected]\dialog\file.go: func (f *fileDialog) setLocation(dir fyne.URI) error {}

Here is the code where the issue is: newDir := storage.NewFileURI(buildDir) isDir, err := storage.CanList(newDir) if err != nil { return err }

Notice that setLocation takes a fyne URL as input (dir fyne.URI). If the fyne URL has a scheme of "file" then the call to storage.NewFileURI(buildDir) above will work. If the fyne URL in the parameter (dir fyne.URI) has a scheme different than "file". Then the call to storage.NewFileURI(buildDir) will return a URL with the "file" scheme instead of the scheme passed in dir fyne.URI.

I found this bug when trying to use the respository "httpfile" that I created.

How to reproduce

Create a non "file" repository. Create a new file dialog pointing to the non "file" repository Try traversing directories in the non "file" repository. The UI will stop once storage.NewFileURI(buildDir) resturns an invalid "file" URI.

Screenshots

No response

Example code

Create a new file dialog using the following code:

locationURI, err := storage.ParseURI("httpfile:///")
	if err != nil {
		return err
	}
	listableURI, err := storage.ListerForURI(locationURI)
	if err != nil {
		return err
	}
	folderdialog := dialog.NewFolderOpen(callback, parent)
	folderdialog.SetLocation(listableURI)
	folderdialog.Show()

Fyne version

2.5.2

Go compiler version

1.23.1

Operating system and version

Windows 11

Additional Information

No response

brucealthompson avatar Oct 18 '24 00:10 brucealthompson