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

Overpass query failes writing to a public directory #167

Open
sebicodes opened this issue Sep 3, 2024 · 1 comment
Open

Overpass query failes writing to a public directory #167

sebicodes opened this issue Sep 3, 2024 · 1 comment

Comments

@sebicodes
Copy link

Hello,

concerning v1.26 (40) from f-droid, on an android 13 phone; overpass-queries:

I encounter problems if I change the folder for the internal data to the former ~/aat_data folder:

If I use the restricted /data/data/ch.bailu.aat/files everything works fine - but I don't have access to the files for further use.

If I change the folder for internal files to primary:aat_data (via "Auswählen (SAF)..." and giving read and write access) the the overpass-query fails: I get the red status message #

GET '....': failed°

Interestingly the nominatim query works with both settings, also the saving of tiles and gpx tracks works properly.

Contents of aat_data/query/nominatim with just one xml-file.
-rw-r--r-- 1 owner group 9 Sep 03 10:28 edit.txt
-rw-r--r-- 1 owner group 1257 Sep 03 10:28 nominatim.xml
-rw-r--r-- 1 owner group 9 Sep 03 10:28 query.txt

Contents of aat_data/query/overpass with newly created xml-files every try:
-rw-r--r-- 1 owner group 19 Sep 03 10:30 edit.txt
-rw-r--r-- 1 owner group 0 Aug 24 14:28 overpass.osm (1).xml
-rw-r--r-- 1 owner group 0 Aug 24 14:28 overpass.osm (2).xml
-rw-r--r-- 1 owner group 0 Aug 24 14:29 overpass.osm (3).xml
-rw-r--r-- 1 owner group 0 Aug 30 10:56 overpass.osm (4).xml
-rw-r--r-- 1 owner group 0 Sep 03 10:23 overpass.osm (5).xml
-rw-r--r-- 1 owner group 0 Sep 03 10:28 overpass.osm (6).xml
-rw-r--r-- 1 owner group 0 Aug 24 14:18 overpass.osm.xml
-rw-r--r-- 1 owner group 19 Sep 03 10:28 query.txt
(same behaviour if I delete all xml files: After that I have the same reaction with the empty overpass.osm.xml-file)

It looks to me very strongly like an issue in access rights or path names at some point.

Maybe it has something to do with issue #164, especially the problem described by @Xanatos00 in #164 (comment)

For some reason, one month ago, AAT was not able to write in my original folder (/emulated/0/t_data/), the only folder working was /data/data/ch.bailu.aat

@bailuk
Copy link
Owner

bailuk commented Sep 10, 2024

    private boolean createDocumentNoException(String mimeType) {
        try {
            return DocumentsContract.createDocument(
                    resolver,
                    uris.getParent(),
                    mimeType,
                    getName()) != null;
        } catch (Exception e) {
            return false;
        }
    }

Document is primary:aat_data/query/overpass/overpass.osm and mimeType is application/xml

    public static String fromName(String name) {
        String suffix = getSuffix(name);

        if ("gpx".equals(suffix)) {
            return "application/gpx+xml";

        } else if ("osm".equals(suffix) || "xml".equals(suffix)) {
            return "application/xml";

        } else if ("png".equals(suffix)) {
            return "image/png";

        } else if ("zip".equals(suffix)) {
            return "application/zip";
        }
        return "text/plain";
    }

So then Android changes the file name to overpass.osm.xml and to make things even worse it also "invents" overpass.osm(1).xml and so on. The error itself comes from overpass.osm not existing.

https://developer.android.com/reference/android/provider/DocumentsContract#createDocument(android.content.ContentResolver,%20android.net.Uri,%20java.lang.String,%20java.lang.String)

I think one workaround is to save overpass results as overpass.xml and hope it works for the next two Android releases.

bailuk added a commit that referenced this issue Sep 10, 2024
…to prevent renaming of file by Android SAF backend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants