Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
brucealthompson opened this issue Oct 18, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@brucealthompson
Copy link

brucealthompson commented Oct 18, 2024

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • 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 brucealthompson added the unverified A bug that has been reported but not verified label Oct 18, 2024
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Oct 18, 2024
@andydotxyz andydotxyz added this to the E fixes (v2.5.x) milestone Oct 18, 2024
@brucealthompson
Copy link
Author

Here's the fix:
```
newURL := dir.Scheme() + "://" + filepath.ToSlash(buildDir)
newDir, err := storage.ParseURI(newURL)
if err != nil {
return err
}

isDir, err := storage.CanList(newDir)
if err != nil {
return err
}

brucealthompson added a commit to brucealthompson/fyne that referenced this issue Oct 19, 2024
@brucealthompson
Copy link
Author

Pull request created:
#5215

@andydotxyz
Copy link
Member

As noted on the PR I don't think that is a fix - it looks like a workaround for your repository.
In a situation where the URI represents something other than another file system (like a media library or an LDAP directory) this will still create very strange results and/or not work at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants