fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.94k stars 1.38k forks source link

Android always returns true from CanWrite #3255

Open bon-ami opened 2 years ago

bon-ami commented 2 years ago

Checklist

Describe the bug

  1. storage.CanWrite() always return true?
  2. storage.Writer() cannot create a file to write?

I am not sure whether it is bug or I did not do it correctly.

How to reproduce

I can only create a writer if the file exists, or use dialog.ShowFileSave()

Screenshots

No response

Example code

// I can successfully storage.Writer() with sss="content://com.android.externalstorage.documents/document/primary%3A.cc%2Fl", which is file l under .cc on internal storage (/sdcard/), if file l exists. But following fails if file la does not exist.
        uri, err = storage.ParseURI(sss + "a")
        if err != nil { // not here
            return nil, err
        }
        if uri == nil { // not here
            return nil, err
        }
        b, err := storage.CanWrite(uri)
        if err != nil { // not here
            return nil, err
        } // b is true
        wr, err := storage.Writer(uri) // fails here

Fyne version

2.2.3

Go compiler version

1.18.4

Operating system

Android

Operating system version

Android 9

Additional Information

No response

andydotxyz commented 2 years ago

I think the issue here is that we cannot create files into the "content://" area (AFAIK). Updated to be a bug that CanWrite is returning true when it shouldn't