phpbg / easysync

Synchronize your android phone/tablet with your DAV server, the easy way.
MIT License
106 stars 6 forks source link

java.io.FileNotFoundException: /storage/...: open failed: EACCES (Permission denied) #30

Closed zerodeux closed 8 months ago

zerodeux commented 8 months ago

Describe the bug Just installed EasySync via F-Droid, got the setup fine with an Apache-based DAV server. Simple, no-nonsense, I like it.

However when I start the sync process, the directory tree layout is created on the DAV server (thus auth and write access is fine), but no files are transferred. The UI does not state anything and sometimes display "5% done" or "-5% done" (!).

Plugging a cable and running 'adb logcat' I captured this :

03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker: java.io.FileNotFoundException: /storage/emulated/0/Pictures/signal-2023-07-08-19-30-36-960-1.jpg: open failed: EACCES (Permission denied)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at libcore.io.IoBridge.open(IoBridge.java:496)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at java.io.FileInputStream.<init>(FileInputStream.java:159)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okio.Okio__JvmOkioKt.source(JvmOkio.kt:182)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okio.Okio.source(Unknown Source:1)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.RequestBody$Companion$asRequestBody$1.writeTo(RequestBody.kt:167)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:62)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at com.phpbg.easysync.dav.TrafficStatsInterceptor.intercept(TrafficStatsInterceptor.kt:34)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at com.burgstaller.okhttp.AuthenticationCacheInterceptor.intercept(AuthenticationCacheInterceptor.java:45)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at java.lang.Thread.run(Thread.java:919)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at libcore.io.Linux.open(Native Method)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7255)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    at libcore.io.IoBridge.open(IoBridge.java:482)
03-06 15:22:20.651 10602 12505 D MediastoreIdSyncWorker:    ... 23 more

However I granted the Storage right to the app, which the app acknowledges (and I can confirm by checking the Settings/App menu). Those files are viewable by all apps, for instance my File Explorer and Photo Gallery. I really don't know why EasySync get this access denied error. Precision : EasySync cannot open any file, but can obviously traverse and list all folders. In my case those are files in Pictures/, Downloads/, DCIM/ and the usual/documented folders which EasySync handles.

Smartphone (please complete the following information):

phpbg commented 8 months ago

Hi, do you have a way to confirm the file is indeed located at /storage/emulated/0/Pictures/signal-2023-07-08-19-30-36-960-1.jpg? It is not clear wether it is a "permission denied" or the file location that is not correctly computed...

phpbg commented 8 months ago

This seems to be a bug specific to android 10

zerodeux commented 8 months ago

I can confirm the path is correct. I launched a (non-rooted) "terminal app" and could run md5sum on this path, thus I think any app on this phone can actually reach this path. The file appears with attributes -rw-rw--- root everybody.

phpbg commented 8 months ago

The fix will be available soon on the playstore (v1.8)

zerodeux commented 8 months ago

Great, thanks a lot ! (btw I'm using F-Droid)

phpbg commented 8 months ago

F-Droid should be updated too, but it usually takes a few days. You can manually download the apk on the releases page

zerodeux commented 8 months ago

F-Droid published the update today, I installed it, the app asked for a new permission, I clicked on "Sync" and a bit later ... 100%, yes! Thanks a lot.