chvp / NanoLedger

Ledger (plain text accounting) data entry app for Android
MIT License
61 stars 5 forks source link

Cannot edit files synchronized with cloud storage services #161

Closed leocencetti closed 2 months ago

leocencetti commented 2 months ago

It seems like NanoLedger is unable to modify files that are synchronized with cloud storage providers (I've tried GDrive, OneDrive and others). The files can be successfully read, but not written to. Offline availability of the files seems to have no impact.

Reproduction steps
  1. Configure the app to use a ledger stored in a cloud service (Google Drive in my case). Transactions should be successfully loaded.
  2. Add a new transaction, fill all the fields, and press save.
  3. A banner saying "error while writing file" pops up (details below)
Expected behaviour

Writing to synchronized files succeeds

System information

App version: https://github.com/chvp/NanoLedger/releases/tag/v0.4.5 (and previous) Android version: 14

Error log

```bash java.io.FileNotFoundException: Unsupported mode: wa at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:151) at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:737) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1878) at android.content.ContentResolver.openOutputStream(ContentResolver.java:1576) at be.chvp.nanoledger.data.LedgerRepository.appendTo(LedgerRepository.kt:95) at be.chvp.nanoledger.ui.add.AddViewModel$append$1.invokeSuspend(AddViewModel.kt:142) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684) ```

alerque commented 2 months ago

I've been doing this with NextCloud and it does work. Nextcloud sometimes drops the offline availability and I have to open the app to get it to come to its senses, then switch back to NanoLedger for it to find it, but I have that trouble with the Android Nextcloud app in general. The NanoLedger side seems to work and I collect entries from a couple phones that way.

chvp commented 2 months ago

I've also been using it with nextcloud without issues. It seems like the content providers you've tried don't support appending to a file. This is annoying, but not impossible to fix. I can just do the append operation in the app and write the entire file. I assume that when syncing the entire file is pushed anyway, so this shouldn't result in any noticeable differences for the content providers that currently work.

I'll try to get to this issue sooner rather than later (this should only need a few lines of changes).

chvp commented 2 months ago

@leocencetti Any chance you'd be able to give this APK a try? You should just be able to install it above the one from f-droid.

leocencetti commented 2 months ago

@leocencetti Any chance you'd be able to give this APK a try? You should just be able to install it above the one from f-droid.

Hello @chvp, thanks for the quick reply! That seems to work! No error message and the file is updated online correctly.

leocencetti commented 2 months ago

I tested both Google Drive (the one I use primarily), OneDrive and kDrive: the first two work, the last one does not (without any error message, the transaction does not show up after saving).

chvp commented 2 months ago

I'll merge that PR and make a new release tomorrow. Not sure about kdrive. They do seem to have an open app on fdroid, so I'll try that out at some point and see if I can find something in the logs. Is kdrive a blocker for you or can I close this issue when #162 is merged?

leocencetti commented 2 months ago

Thanks! kDrive is a nice to have, but definitely not a blocker!