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

Use libkiwix to store bookmarks #3474

Closed
wants to merge 30 commits into from
Closed

Use libkiwix to store bookmarks #3474

wants to merge 30 commits into from

Conversation

MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Aug 25, 2023

Fixes #3109

  • Upgraded libkiwix to 1.0.1

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft August 25, 2023 12:54
@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (3716b72) 48.98% compared to head (8c46646) 49.69%.

Files Patch % Lines
...rg/kiwix/kiwixmobile/core/dao/LibkiwixBookmarks.kt 68.57% 18 Missing and 15 partials ⚠️
...le/core/data/remote/ObjectBoxToLibkiwixMigrator.kt 44.44% 8 Missing and 2 partials ⚠️
...core/page/bookmark/adapter/LibkiwixBookmarkItem.kt 75.00% 9 Missing and 1 partial ⚠️
.../kiwix/kiwixmobile/core/main/CoreReaderFragment.kt 45.45% 2 Missing and 4 partials ⚠️
...java/org/kiwix/kiwixmobile/core/data/Repository.kt 50.00% 3 Missing ⚠️
...kiwix/kiwixmobile/core/page/viewmodel/PageState.kt 0.00% 3 Missing ⚠️
...rg/kiwix/kiwixmobile/core/main/CoreMainActivity.kt 66.66% 0 Missing and 1 partial ⚠️
...wix/kiwixmobile/core/main/MainRepositoryActions.kt 0.00% 0 Missing and 1 partial ⚠️
...bile/core/page/bookmark/viewmodel/BookmarkState.kt 66.66% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3474      +/-   ##
=============================================
+ Coverage      48.98%   49.69%   +0.71%     
- Complexity      1076     1132      +56     
=============================================
  Files            285      288       +3     
  Lines          10422    10603     +181     
  Branches        1396     1415      +19     
=============================================
+ Hits            5105     5269     +164     
+ Misses          4493     4482      -11     
- Partials         824      852      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz Have you secured that the bookmark related Objectbox is only there for the google play build?

@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz Have you secured that the bookmark related Objectbox is only there for the google play build?

Yes google play build also works since we are using libkiwix to store bookmark instead of Objectbox, Old playstore users who are using Objectbox will automatically migrate to new libkiwix boomark.

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz Your answer is not what i ask for. I ask for non-PS builds (apk, fdroid)

@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz Your answer is not what i ask for. I ask for non-PS builds (apk, fdroid)

@kelson42 Yes it will work for non-playstore builds as well. e.g. for nightly builds(APK) and fdroid builds but for now, we can not publish our apk on fdroid since we have ObjectBox in our codebase.

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz yes, but still secure that the objectbox bookmark related code is already not included in those builds.

1 similar comment
@kelson42
Copy link
Collaborator

@MohitMaliFtechiz yes, but still secure that the objectbox bookmark related code is already not included in those builds.

@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz yes, but still secure that the objectbox bookmark related code is already not included in those builds.

@kelson42 We need the ObjectBox-related code for the migration of existing bookmarks to libkiwix. For the upcoming version of our application, we can only remove some functions of the ObjectBox bookmarks e.g. save/delete but we need the implementation of the bookmarks as we need the existing list of the bookmarks from objectbox for migration.

@kelson42
Copy link
Collaborator

no migration for fdroid (objectbox is forbidden there), but ok for our apk (not sure what was decided with gouri).

@MohitMaliFtechiz
Copy link
Collaborator Author

@mgautierfr Sorry to be late on this I was busy with other tickets, but now I figured out the problem I was facing while reading the books from the library object.

  • Previously, the Library removed the books from it and I was unable to get the zimFilePath for the bookmarks. I thought it was an Android code error(Probably because I was not writing/reading correctly) so I thoroughly reviewed my code and it looks good, I have tested many scenarios and found it is not an Android code error, this error happened when I am trying to write file with Library.writeToFile method.

Logs When writing a file

writeBookMarksAndSaveLibraryToFile: Trying to write a file with the library.writeFile() method. current books size in the library is = 2

Logs when reading the same file manager.readFile method

readLibraryFromFile: reading books from a file via the manager.readFile() method current books size = 1
LibraryIssue.mp4

So it is not probably not writing a library to file properly.

Apart from this method, I am facing one more issue, the library has the book object and it has an illustration for the book, but when I try to get the illustration. data from the book object it is giving me an error.

library contains this data in it.

<library version="20110515">
  <book id="78603798-2235-9c50-24ae-3fdaf25ee355" path="../../Kiwix/wikipedia_af_all_maxi_2023-09.zim" title="Wikipedia" description="aflyn weergawe van Wikipedia in Afrikaans" language="afr" creator="Wikipedia" publisher="Kiwix" name="wikipedia_af_all" flavour="maxi" tags="wikipedia;_category:wikipedia;_pictures:yes;_videos:no;_details:yes;_ftindex:yes" faviconMimeType="text/plain" favicon="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAARQklEQVR4nO1ZeWyb93lm2qEbumDZihXdOgz7Y1uLDMu6biuQYS2WDeiwoWiKLHPTtUuwOHZ8yI5jO3Z8h9ZF3RctWTclkRJv6qYpURJJibolUhdJiSJF8RBlWZJt+ZBsx+Y7PO+nT3HawE07d90f+QE/UKT4fd97PO/zPu+PEsln67O1s3Q63XOVlZVfkjztJSX63NTUTK7X67N1dts6y8vLv/Y07qtWN3+13WL515YW84tVNcpX9QZT1NTUGtCZTN+VPK21sUFf6uvrLwiFFim0GKEGjS6YUVb23M+7zuWa+vu5uflGl3ui02g0/gk+k0qln3M4HM/b7b0HHL3Oph6bY83R10+d1u47JlOzSqPVb7a2XaGmlvatxqa2IpVK9a3/lfFut/u7vY7e+ZHhUbJ0WEmt09srFIrvfJprNRpN6VJ8mcKRKLlcE5rxcXf+uMs9Mj4+seVyTxD2wOAQ2R19ZLP3Ule3neobNIn3T54imSyTKiqrSWcw3VSoVC/+UsbH46t/43K5bxgNRorFlsjrmyWt3pj5pGs8Hs+zHs/8N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9GA/cY/6F9h9i7A+RLD2D/vHb36EffP9llsyqejUXLnQ/jlTQuFLTM1xFRUW/I/k0y+/3/3UwGFoH9qFZEEVxCIFT3IgiwtGI2JSQJRiO7/vnBdjM+f0cecy/EGpwQDQcR4k9NgerzsbGFqpT1tOB/Qe5YYHzi+QllF8o325aOWtpadl/JflFls/n+/7Y2PgWBg7wNQSXWIgwElt8D1WJ9zjvFI0XJ62paeHgyuHo4z24rTbFmbetHT9otOG3AUpKOsRTFw6vcPIA6OTkFWyy7v9lVlNT62t6vWHT6exn4zA1iUWJeVbgeOB7Xjhxnpji3wNAkXCYadLlZrxDZWJQwW8BGFagMltx/tnYzAdXwPrZs+d57i0pLadLxZepoPDSXZks65PPQj/t6unp/Z66Qb0yNDTCqYdBcAZ7ZsbLUQa+YTReMSYyxsdcHG1cNzAwxEeHEGnCSYOFqdJoauKChVCrrVMx1wP3JZfLoXmu8sDyNJZCoXhBXiQfaG8374x/wDKMBKOgk+L8X683UFdXD+MbxdmxfUyCHzUQbTSmxqZmpklEvUGjY8jU1KlY5wD3xSWllJtX1J+Wlv2Xkqe5srOzf9tisSQ7HH230PZxdgPViKNARBYUaLF08mctrW1kMjVRuxlyoJF0eiMZjI2CNFBr2BE1DqnqwTY4aSvlWVcqTb51/gPpRalU+kXJr2pZrdYXurttyp4e+yYG8I5OK8OitlZJl+TFVFJymSoqqujM6TMcdUiDpuZWxjoMx3CCguWT5koFpcsy6fyFi5uyzJw6ubzshV+Z4Z/kiNXanW02d/gBCTih0xk44uiiWnHrDJwBRByGVytqeZdVVAE2/kJ5cbZCpfq/M/ynl06ne1av17+kM5guqLW6Nq3OMKvTG9e1OsPWpeLLDy9eTH5YWHRpq6ZOtaaoqfWVlle0XiopvXC5ouKl4uLiZyX/3xZ+PVEoFH9QW1v7NaVS843SqqpvlJYq/ryiouIrRUVFv/nrtu+zJXnK638AM6p7hAbGBRoAAAAASUVORK5CYII=" date="2023-09-02" articleCount="110800" mediaCount="145624" size="1465527" />
</library>
 public native Illustration get illustration(int size);

Error it is showing

pid: 19731, tid: 19772, name: RxCachedThreadS  >>> org.kiwix.kiwixmobile <<<
A        #10 pc 000000000001f0f4  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/base.apk!libkiwix_wrapper.so (Java_org_kiwix_libkiwix_Illustration_getData+156) (BuildId: d509aa2e940c165a50d156c0469c5234d4108a96)
A        #17 pc 0000000000009e46  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.getBookmarksList+538)
A        #23 pc 0000000000009a7a  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.access$getBookmarksList+18)
A        #26 pc 0000000000008fd0  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks$bookmarkListBehaviour$2.invoke+12)
A        #32 pc 0000000000009000  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks$bookmarkListBehaviour$2.invoke+8)
A        #37 pc 000000000078369a  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (kotlin.SynchronizedLazyImpl.getValue+80)
A        #43 pc 0000000000009924  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.getBookmarkListBehaviour+12)
A        #49 pc 000000000000a8c6  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.flowableBookmarkList$lambda-19+38)
A        #52 pc 000000000000a2d8  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.$r8$lambda$cGKTklQTmUYsuOCbDLX4HqreYBg+0)
A        #55 pc 0000000000008dc8  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks$$ExternalSyntheticLambda4.subscribe+4)
A        #60 pc 00000000006dff4e  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual+146)
A        #65 pc 00000000006b5f66  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.Flowable.subscribe+62)
A        #70 pc 00000000006f0eb8  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual+78)
2023-11-03 18:48:49.336 19925-19925 DEBUG                   pid-19925                           pid: 19731, tid: 19772, name: RxCachedThreadS  >>> org.kiwix.kiwixmobile <<<
A        #10 pc 000000000001f0f4  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/base.apk!libkiwix_wrapper.so (Java_org_kiwix_libkiwix_Illustration_getData+156) (BuildId: d509aa2e940c165a50d156c0469c5234d4108a96)
A        #17 pc 0000000000009e46  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.getBookmarksList+538)
A        #23 pc 0000000000009a7a  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.access$getBookmarksList+18)
A        #26 pc 0000000000008fd0  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks$bookmarkListBehaviour$2.invoke+12)
A        #32 pc 0000000000009000  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks$bookmarkListBehaviour$2.invoke+8)
A        #37 pc 000000000078369a  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (kotlin.SynchronizedLazyImpl.getValue+80)
A        #43 pc 0000000000009924  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.getBookmarkListBehaviour+12)
A        #49 pc 000000000000a8c6  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.flowableBookmarkList$lambda-19+38)
A        #52 pc 000000000000a2d8  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks.$r8$lambda$cGKTklQTmUYsuOCbDLX4HqreYBg+0)
A        #55 pc 0000000000008dc8  /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes2.dex (org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks$$ExternalSyntheticLambda4.subscribe+4)
A        #60 pc 00000000006dff4e  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual+146)
A        #65 pc 00000000006b5f66  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.Flowable.subscribe+62)
A        #70 pc 00000000006f0eb8  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual+78)
A        #75 pc 00000000006b5f66  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.Flowable.subscribe+62)
A        #80 pc 00000000006b6002  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.Flowable.subscribe+32)
A        #85 pc 000000000070217a  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run+40)
A        #90 pc 000000000075ed84  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.schedulers.ScheduledRunnable.run+40)
A        #95 pc 000000000075eb60  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.schedulers.ScheduledRunnable.call+8)
A        #75 pc 00000000006b5f66  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.Flowable.subscribe+62)
A        #80 pc 00000000006b6002  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.Flowable.subscribe+32)
A        #85 pc 000000000070217a  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run+40)
A        #90 pc 000000000075ed84  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.schedulers.ScheduledRunnable.run+40)
A        #95 pc 000000000075eb60  /data/app/~~zahB8XNGeTaxc8wT7PQJQg==/org.kiwix.kiwixmobile-VznQm-J2n72KVceDytHSPA==/oat/arm64/base.vdex (io.reactivex.internal.schedulers.ScheduledRunnable.call+8)

or i am missing something?

@mgautierfr
Copy link
Member

Let's do one issue at the time.

Previously, the Library removed the books from it and I was unable to get the zimFilePath for the bookmarks. I thought it was an Android code error(Probably because I was not writing/reading correctly) so I thoroughly reviewed my code and it looks good, I have tested many scenarios and found it is not an Android code error, this error happened when I am trying to write file with Library.writeToFile method.

This is the first thing to fix/understand.
What is the content of the written library.xml ?
Which book is missing ? Does it have something special ? What is its path ?

@MohitMaliFtechiz
Copy link
Collaborator Author

@mgautierfr

What is the content of the written library.xml ?

This is the content of the library.

<library version="20110515">
  <book id="78603798-2235-9c50-24ae-3fdaf25ee355" path="../../Kiwix/wikipedia_af_all_maxi_2023-09.zim" title="Wikipedia" description="aflyn weergawe van Wikipedia in Afrikaans" language="afr" creator="Wikipedia" publisher="Kiwix" name="wikipedia_af_all" flavour="maxi" tags="wikipedia;_category:wikipedia;_pictures:yes;_videos:no;_details:yes;_ftindex:yes" faviconMimeType="text/plain" favicon="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAARQklEQVR4nO1ZeWyb93lm2qEbumDZihXdOgz7Y1uLDMu6biuQYS2WDeiwoWiKLHPTtUuwOHZ8yI5jO3Z8h9ZF3RctWTclkRJv6qYpURJJibolUhdJiSJF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xlyoJF0eiMZjI2CNFBr2BE1DqnqwTY4aSvlWVcqTb51/gPpRalU+kXJr2pZrdYXurttyp4e+yYG8I5OK8OitlZJl+TFVFJymSoqqujM6TMcdUiDpuZWxjoMx3CCguWT5koFpcsy6fyFi5uyzJw6ubzshV+Z4Z/kiNXanW02d/gBCTih0xk44uiiWnHrDJwBRByGVytqeZdVVAE2/kJ5cbZCpfq/M/ynl06ne1av17+kM5guqLW6Nq3OMKvTG9e1OsPWpeLLDy9eTH5YWHRpq6ZOtaaoqfWVlle0XiopvXC5ouKl4uLiZyX/3xZ+PVEoFH9QW1v7NaVS843SqqpvlJYq/ryiouIrRUVFv/nrtu+zJXnK638AM6p7hAbGBRoAAAAASUVORK5CYII=" date="2023-09-02" articleCount="110800" mediaCount="145624" size="1465527" />
</library>

Which book is missing ? Does it have something special ?

Previously, added books are missing it is only showing books for the last added zim file.

What is its path ?

I am writing it inside the public directory/kiwix/bookmarks, but I think it does not matter as we are able to read and write the file at that path.

 sharedPreferenceUtil.getPublicDirectoryPath(
        sharedPreferenceUtil.defaultStorage()
      ) + "/kiwix/Bookmarks/"

@mgautierfr
Copy link
Member

Previously, added books are missing it is only showing books for the last added zim file.

Can you loop over the books in the library and print its name/id/path before you write the library (where you are printing Trying to write a file with the library.writeFile() method. current books size in the library is = 2)

I am writing it inside the public directory/kiwix/bookmarks

Are we speaking about bookmarks or book ?

@MohitMaliFtechiz
Copy link
Collaborator Author

@mgautierfr
while writing books via the library into file.

2023-11-07 16:23:52.734 15652-16336 LibkiwixBookmark        org.kiwix.kiwixmobile                E  Trying to write a file with the library.writeFile() method. current books size in the library is = 2 
                                                                                                     book path = /storage/emulated/0/Kiwix/alpinelinux_en_all_maxi_2023-01.zim
                                                                                                    book title = Alpine Linux Wiki
                                                                                                    book name = alpinelinux_en_all
                                                                                                    book id = 1f88ab6f-c265-b3ff-8f49-b7f442950380
2023-11-07 16:23:52.734 15652-16336 LibkiwixBookmark        org.kiwix.kiwixmobile                E  Trying to write a file with the library.writeFile() method. current books size in the library is = 2 
                                                                                                     book path = /storage/emulated/0/Kiwix/wikipedia_af_all_maxi_2023-09.zim
                                                                                                    book title = Wikipedia
                                                                                                    book name = wikipedia_af_all
                                                                                                    book id = 78603798-2235-9c50-24ae-3fdaf25ee355

While reading books from library.

2023-11-07 16:26:23.159 18098-18098 LibkiwixBookmark        org.kiwix.kiwixmobile                E  readLibraryFromFile reading books from a file via the manager.readFile() method current books size current books size in the library is = 1 
                                                                                                     book path = /storage/emulated/0/Kiwix/alpinelinux_en_all_maxi_2023-01.zim
                                                                                                    book title = Alpine Linux Wiki
                                                                                                    book name = alpinelinux_en_all
                                                                                                    book id = 1f88ab6f-c265-b3ff-8f49-b7f442950380

Are we speaking about bookmarks or book ?

Yes we are here talking about the bookmark and book, we are saving bookmark/library inside public directory/kiwix/bookmarks folder.

@kelson42
Copy link
Collaborator

kelson42 commented Nov 7, 2023

@MohitMaliFtechiz This is a side comment. I understand you write the library.xml only for the bookmarks for the moment, but this won't be like this anymore. So please just write both libraty and bookmark XML files directly at the root directory/kiwix

@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz This is a side comment. I understand you write the library.xml only for the bookmarks for the moment, but this won't be like this anymore. So please just write both libraty and bookmark XML files directly at the root directory/kiwix

@kelson42 For now we are writing the bookmarks at root directory of the device.

Root directory Inside kiwix
1699358243855 1699358251740

or are you talking about the root directory of our app-specific directory?

@mgautierfr
Copy link
Member

Where is the code loading and writing the library (with the log message) ? In this PR ?

@MohitMaliFtechiz
Copy link
Collaborator Author

@mgautierfr Here is the code that loads the data from the file

and this code writes the data into the file

private fun writeBookMarksAndSaveLibraryToFile() {

@kelson42
Copy link
Collaborator

kelson42 commented Nov 7, 2023

or are you talking about the root directory of our app-specific directory?

Yes, I see no reason to have a "bookmark" folder.... in particular if you write library.xml in it.

@mgautierfr
Copy link
Member

mgautierfr commented Nov 7, 2023

This is the content of the library.

<library version="20110515">
 <book id="78603798-2235-9c50-24ae-3fdaf25ee355" path="../../Kiwix/wikipedia_af_all_maxi_2023-09.zim" title="Wikipedia" description="aflyn weergawe van Wikipedia in Afrikaans" language="afr" creator="Wikipedia" publisher="Kiwix" name="wikipedia_af_all" flavour="maxi" tags="wikipedia;_category:wikipedia;_pictures:yes;_videos:no;_details:yes;_ftindex:yes" faviconMimeType="text/plain" favicon="[...]" date="2023-09-02" articleCount="110800" mediaCount="145624" size="1465527" />
</library>

The path ../../Kiwix/wikipedia_af_all_maxi_2023-09.zim is surprising if you store library.xml
in sharedPreferenceUtil.defaultStorage() + "/kiwix/Bookmarks/"

The path should be ../wikipedia_af_all_maxi_2023-09.zim.

And be careful Kiwix (in path) is different than kiwix (in directory where is stored library.xml)

Are you sure you are checking the right library.xml ?
Maybe the file is written in sharedPreferenceUtil.context.filesDir.path because of dd4f39a#diff-7d55b21215f3807faf00cb902692f9f4d2d98efdd4ad7a543520247bd6133e9aR55-R59

@MohitMaliFtechiz
Copy link
Collaborator Author

And be careful Kiwix (in path) is different than kiwix (in directory where is stored library.xml)

Hoo! Thanks, I have corrected this, somehow my storage is creating the XML file in the same directory.

Now library.xml looks like

<library version="20110515">
<book id="78603798-2235-9c50-24ae-3fdaf25ee355" path="../wikipedia_af_all_maxi_2023-09.zim" title="Wikipedia" description="aflyn weergawe van Wikipedia in Afrikaans" language="afr" creator="Wikipedia" publisher="Kiwix" name="wikipedia_af_all" flavour="maxi" tags="wikipedia;_category:wikipedia;_pictures:yes;_videos:no;_details:yes;_ftindex:yes" faviconMimeType="text/plain" favicon="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAARQklEQVR4nO1ZeWyb93lm2qEbumDZihXdOgz7Y1uLDMu6biuQYS2WDeiwoWiKLHPTtUuwOHZ8yI5jO3Z8h9ZF3RctWTclkRJv6qYpURJJibolUhdJiSJF8RBlWZJt+ZBsx+Y7PO+nT3HawE07d90f+QE/UKT4fd97PO/zPu+PEsln67O1s3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dYXurttyp4e+yYG8I5OK8OitlZJl+TFVFJymSoqqujM6TMcdUiDpuZWxjoMx3CCguWT5koFpcsy6fyFi5uyzJw6ubzshV+Z4Z/kiNXanW02d/gBCTih0xk44uiiWnHrDJwBRByGVytqeZdVVAE2/kJ5cbZCpfq/M/ynl06ne1av17+kM5guqLW6Nq3OMKvTG9e1OsPWpeLLDy9eTH5YWHRpq6ZOtaaoqfWVlle0XiopvXC5ouKl4uLiZyX/3xZ+PVEoFH9QW1v7NaVS843SqqpvlJYq/ryiouIrRUVFv/nrtu+zJXnK638AM6p7hAbGBRoAAAAASUVORK5CYII=" date="2023-09-02" articleCount="110800" mediaCount="145624" size="1465527"/>
</library>

Bu error is the same after changing this.

writeBookMarksAndSaveLibraryToFile: Trying to write a file with the library.writeFile() method. current books size in the library is = 2
                                                                                                    book path = /storage/emulated/0/Kiwix/alpinelinux_en_all_maxi_2023-01.zim
                                                                                                    book title = Alpine Linux Wiki
                                                                                                    book id = 1f88ab6f-c265-b3ff-8f49-b7f442950380
2023-11-07 19:51:29.938   834-1623  LibkiwixBookmark        org.kiwix.kiwixmobile                E  writeBookMarksAndSaveLibraryToFile: Trying to write a file with the library.writeFile() method. current books size in the library is = 2
                                                                                                    book path = /storage/emulated/0/Kiwix/wikipedia_af_all_maxi_2023-09.zim
                                                                                                    book title = Wikipedia
                                                                                                    book id = 78603798-2235-9c50-24ae-3fdaf25ee355
                                                                                                    
                                                                                                    readLibraryFromFile: reading books from a file via the manager.readFile() method current books size current books size in the library is = 1
                                                                                                    book path = /storage/emulated/0/Kiwix/wikipedia_af_all_maxi_2023-09.zim
                                                                                                    book title = Wikipedia
                                                                                                    book id = 78603798-2235-9c50-24ae-3fdaf25ee355

Are you sure you are checking the right library.xml ?

Yes, we are checking reading/writing on the same file.

@mgautierfr
Copy link
Member

Ok, I have found the problem.

C++ readFile has an argument readOnly to mark the library (and the books inside) to be readOnly. This is a really old feature, I don't even know why it is here (@kelson42 may remember why). But anyway, it is here.

Strangely, readOnly doesn't really means that we cannot modify the library (even if, in some case, but not always, books may not be update if they are marked as readOnly). It means that we only read the library (and the books within), and so, never write them.

C++ readFile has a default value of true for readOnly and the java wrapper use that.
Meaning that all books read from the library will not be saved, only the newly added (which will not be saved the next time you load/save the library).

We have to:

  • Adapt java-libkiwix to provide access to this attribute.
  • Totally remove this attribute as I don't really see why it is here (@kelson42 ?)

@MohitMaliFtechiz
Copy link
Collaborator Author

OK, I have found the problem.
C++ readFile has an argument readOnly to mark the library (and the books inside) to be readOnly. This is a really old feature, I don't even know why it is here (@kelson42 may remember why). But anyway, it is here.
Strangely, readOnly doesn't really means that we cannot modify the library (even if, in some case, but not always, books may not be update if they are marked as readOnly). It means that we only read the library (and the books within), and so, never write them.

@mgautierfr Ohh! Thanks for finding the actual bug.

This means that all books read from the library will not be saved, only the newly added (which will not be saved the next time you load/save the library).

Yes, exactly this is the same scenario I am facing.

We have to:
Adapt java-libkiwix to provide access to this attribute.
Totally remove this attribute as I don't really see why it is here (@kelson42 ?)

I assume this will be fixed when we make these changes.

Let's do one issue at the time.

Now we have another issue related to the Illustration see #3474 (comment).

@mgautierfr
Copy link
Member

Now we have another issue related to the Illustration see #3474 (comment).

Please open a new specific issue for this. We will lost our mind if we discuss about several issues in a PR discussion.

mgautierfr added a commit to kiwix/java-libkiwix that referenced this pull request Nov 9, 2023
The readOnly argument of `readFile` is to put the loaded library in
readOnly mode. Which kinda means "Do not write again what is loaded".

We don't want that for android as we want to save again our
(potentially modified) library.

See kiwix/kiwix-android#3474
MohitMaliDeveloper and others added 27 commits November 16, 2023 12:35
…ted flowables to perform bookmarks operation on background thread for better user experience.
…n, improved the delete functionality in the bookmark screen, and also refactored the add/delete bookmark functionality in the reader fragment.
* We introduced a Flowable list in LibkiwixBookmarks to observe live changes on the UI. Previously, the UI was not updating after deleting bookmarks on the BookmarkScreen, and toggling bookmarks in the reader screen was also not reflecting the changes. To address this, we created a Flowable list and are now observing it whenever bookmarks are added or removed in the library.
…save the `library`, which contains information about books, their file paths, and favicons, into a file.

* We now save this library information into a file named `library.txt` and subsequently read from it to retrieve file paths and favicons.
* The test cases have been refactored to accommodate this new functionality.
* The `ObjectBoxToLibkiwiMigrator` code has also been enhanced. With this change, we now save books in the library for their favicon and zimFilePath, resulting in a refactor and improvement of this class's functionality and its associated test cases.
* The process of writing bookmarks and library data to file has been enhanced. Now, this is performed asynchronously in a background thread to mitigate potential data loss.
* Additionally, several other improvements have been made throughout the codebase.
… since we don't need these classes as saving/deleting functionality will be tested in java-libkiwix.

* Added instrumentation test case for testing the UI part with libkiwix bookmark functionality.
…etrieve the saved bookmarks.

* Enhanced the `isBookMarkExist` method, addressing a bug that prevented the addition of new bookmarks for the same file. The method has been refactored for improved functionality.
* In the debug version, added informative logs to provide developers with insights into the bookmark-saving functionality.
…e current book has been removed because adding the book to the library is unnecessary, as we have not saved any bookmarks yet.

* We now write bookmarks and the library on the main thread instead of saving them in the background thread to prevent any data loss.
…he favicon from it, we are now speeding up the process by directly taking the favicon from the book, as the issue at kiwix/java-libkiwix#73 has been resolved.
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

Successfully merging this pull request may close these issues.

Use libkiwix to store bookmarks
4 participants