mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-11 16:37:18 -04:00
Merge pull request #3757 from kiwix/Fix#3756
Fixed: Migration of bookmarks is not working with recent versions of custom apps.
This commit is contained in:
commit
d4a3db11ce
@ -55,15 +55,22 @@ class ObjectBoxToLibkiwixMigrator {
|
|||||||
try {
|
try {
|
||||||
// for saving book to library, otherwise it does not save the
|
// for saving book to library, otherwise it does not save the
|
||||||
// favicon and zimFilePath in library.
|
// favicon and zimFilePath in library.
|
||||||
val archive = Archive(bookmarkEntity.zimFilePath)
|
var archive: Archive? = null
|
||||||
val libkiwixBook = Book().apply {
|
val libkiwixBook = bookmarkEntity.zimFilePath?.let {
|
||||||
update(archive)
|
archive = Archive(bookmarkEntity.zimFilePath)
|
||||||
|
Book().apply {
|
||||||
|
update(archive)
|
||||||
|
}
|
||||||
|
} ?: kotlin.run {
|
||||||
|
// for migrating bookmarks for recent custom apps since in recent version of
|
||||||
|
// custom app we are using the `assetFileDescriptor` which does not have the filePath.
|
||||||
|
null
|
||||||
}
|
}
|
||||||
libkiwixBookmarks.saveBookmark(
|
libkiwixBookmarks.saveBookmark(
|
||||||
LibkiwixBookmarkItem(bookmarkEntity, libkiwixBook),
|
LibkiwixBookmarkItem(bookmarkEntity, libkiwixBook),
|
||||||
shouldWriteBookmarkToFile = index == bookMarksList.size - 1
|
shouldWriteBookmarkToFile = index == bookMarksList.size - 1
|
||||||
)
|
)
|
||||||
archive.dispose()
|
archive?.dispose()
|
||||||
// TODO should we remove data from objectBox?
|
// TODO should we remove data from objectBox?
|
||||||
// removing the single entity from the object box after migration.
|
// removing the single entity from the object box after migration.
|
||||||
// box.query {
|
// box.query {
|
||||||
|
@ -68,7 +68,7 @@ data class LibkiwixBookmarkItem(
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
bookmarkEntity: BookmarkEntity,
|
bookmarkEntity: BookmarkEntity,
|
||||||
libkiwixBook: Book
|
libkiwixBook: Book?
|
||||||
) : this(
|
) : this(
|
||||||
zimId = bookmarkEntity.zimId,
|
zimId = bookmarkEntity.zimId,
|
||||||
zimFilePath = bookmarkEntity.zimFilePath,
|
zimFilePath = bookmarkEntity.zimFilePath,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user