cryptomator / android

Cryptomator for Android
https://cryptomator.org
GNU General Public License v3.0
744 stars 123 forks source link

Auto upload fails due to permission problem on some devices #434

Open SailReal opened 2 years ago

SailReal commented 2 years ago

Please agree to the following

Summary

Auto upload fails due to permission problem while reading the file during upload

System Setup

- Android: 12 (GrapheneOS) on Pixel 4a
- Cryptomator: 1.7.1 (F-Droid)

Cloud Type

No response

Steps to Reproduce

  1. Enable auto upload
  2. Create some pictures
  3. Unlock vault or have the vault in an unlocked state

Expected Behavior

Pictures gets uploaded

Actual Behavior

Upload fails due to permission exception while accessing the picture.

Reproducibility

Always

Relevant Log Output

AutoUploadNotification  Show storage permission required notification
AutoUploadService   Failed to auto upload image(s).
org.cryptomator.domain.exception.FatalBackendException: java.io.FileNotFoundException: /storage/emulated/0/Pictures/Icons/Tutanota_Icon.png: open failed: EACCES (Permission denied)
    at org.cryptomator.data.cloud.crypto.CryptoImplDecorator.writeShortNameFile(CryptoImplDecorator.kt:451)
    at org.cryptomator.data.cloud.crypto.CryptoImplVaultFormat7.write(CryptoImplVaultFormat7.kt:437)
    at org.cryptomator.data.cloud.crypto.CryptoCloudContentRepository.write(CryptoCloudContentRepository.kt:90)
    at org.cryptomator.data.cloud.crypto.CryptoCloudContentRepository.write(CryptoCloudContentRepository.kt:21)
    at org.cryptomator.data.repository.DispatchingCloudContentRepository.write(DispatchingCloudContentRepository.kt:149)
    at org.cryptomator.presentation.service.AutoUploadService.writeCloudFile(AutoUploadService.java:219)
    at org.cryptomator.presentation.service.AutoUploadService.upload(AutoUploadService.java:206)
    at org.cryptomator.presentation.service.AutoUploadService.upload(AutoUploadService.java:199)
    at org.cryptomator.presentation.service.AutoUploadService.upload(AutoUploadService.java:175)
    at org.cryptomator.presentation.service.AutoUploadService.lambda$startBackgroundImageUpload$1$org-cryptomator-presentation-service-AutoUploadService(AutoUploadService.java:109)
    at org.cryptomator.presentation.service.AutoUploadService$$ExternalSyntheticLambda1.run(Unknown Source:6)
    at java.lang.Thread.run(Thread.java:920)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Pictures/Icons/Tutanota_Icon.png: open failed: EACCES (Permission denied)
    at libcore.io.IoBridge.open(IoBridge.java:575)
    at java.io.FileInputStream.<init>(FileInputStream.java:160)
    at java.io.FileInputStream.<init>(FileInputStream.java:115)
    at android.content.ContentResolver.openInputStream(ContentResolver.java:1527)
    at org.cryptomator.presentation.util.ContentResolverUtil.openInputStream(ContentResolverUtil.kt:20)
    at org.cryptomator.presentation.presenter.UriBasedDataSource.open(UriBasedDataSource.kt:18)
    at org.cryptomator.domain.usecases.cloud.CancelAwareDataSource.open(CancelAwareDataSource.kt:22)
    at org.cryptomator.data.cloud.crypto.CryptoImplDecorator.writeShortNameFile(CryptoImplDecorator.kt:423)
    ... 11 more
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
    at libcore.io.Linux.open(Native Method)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:273)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
    at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7756)
    at libcore.io.IoBridge.open(IoBridge.java:561)
    ... 18 more

ErrorCode: KNRD:M7LU

Anything else?

I can not reproduce this on a Pixel 6 and Pixel 4 using GrapheneOS too.

According to https://developer.android.com/training/data-storage/shared/media when accessing the MediaStore and with Scoped storage enabled,

See https://github.com/cryptomator/android/blob/55d7f68f4973274b5ff272d43f9fa6847afd264d/presentation/src/main/AndroidManifest.xml#L9

and https://github.com/cryptomator/android/blob/55d7f68f4973274b5ff272d43f9fa6847afd264d/presentation/src/main/java/org/cryptomator/presentation/service/PhotoContentJob.kt#L149-L153

So I have currently no idea what the problem is here :thinking:

kokolem commented 2 years ago

I can not reproduce on Pixel 4a with CalyxOS (Android 12). Perhaps this is a Graphene specific issue?

NeverUsedID commented 1 year ago

I can reproduce it on a pixel 7a with the Whatsapp Media folder. Deleting the folder does not help, as whatsapp recreates it after restart. Fast workaround would be to respect .nomedia file.

Logfile ist here: https://github.com/cryptomator/android/issues/177#issuecomment-1612684136