ARK-Builders / ARK-Navigator

Android app for navigation through your data
MIT License
15 stars 15 forks source link

Adapting to changes in arklib #343

Closed kirillt closed 1 year ago

kirillt commented 1 year ago

This PR adapts Navigator to changes made in the following arklib-android PRs: https://github.com/ARK-Builders/arklib-android/pull/36 https://github.com/ARK-Builders/arklib-android/pull/45

kirillt commented 1 year ago

Deletion of a resource leads to crash:

java.nio.file.NoSuchFileException: /storage/emulated/0/Pictures/Screenshots/Screenshot_20230401-193417_Trebuchet.png
    at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
    at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:115)
    at java.nio.file.Files.readAttributes(Files.java:1737)
    at java.nio.file.Files.size(Files.java:2332)
    at space.taran.arklib.domain.index.Resource$Companion.compute-gIAlu-s(Resource.kt:26)
    at space.taran.arklib.domain.index.ResourceIndexRepo.providePlainIndex$lib_release(ResourceIndexRepo.kt:61)
    at space.taran.arklib.domain.index.ResourceIndexRepo$provide$2.invokeSuspend(ResourceIndexRepo.kt:30)
    at space.taran.arklib.domain.index.ResourceIndexRepo$provide$2.invoke(Unknown Source:8)
    at space.taran.arklib.domain.index.ResourceIndexRepo$provide$2.invoke(Unknown Source:4)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169)
    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
    at space.taran.arklib.domain.index.ResourceIndexRepo.provide(ResourceIndexRepo.kt:26)
    at space.taran.arklib.domain.index.ResourceIndexRepo.provide(ResourceIndexRepo.kt:38)
    at space.taran.arknavigator.mvp.model.repo.tags.TagsStorageRepo$provide$2.invokeSuspend(TagsStorageRepo.kt:36)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@efdaebe, Dispatchers.Main]
mdrlzy commented 1 year ago

Deletion of a resource leads to crash:

Now after deletion we don't update native index / kotlin index Due to the fact that now there is no PlainIndex cache in ResourceIndexRepo, compute is called on all resources, but removed resource is no longer there

kirillt commented 1 year ago

Now, deletion of a resource leads to another crash:

java.lang.NullPointerException
    at space.taran.arknavigator.mvp.presenter.GalleryPresenter.displayPreview(GalleryPresenter.kt:327)
    at space.taran.arknavigator.mvp.presenter.GalleryPresenter.access$displayPreview(GalleryPresenter.kt:56)
    at space.taran.arknavigator.mvp.presenter.GalleryPresenter$onPageChanged$1.invokeSuspend(GalleryPresenter.kt:151)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7870)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@d0ab86, Dispatchers.Main]