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

Every time an e-book is opened a new data base row is created #373

Open
aTom3333 opened this issue Apr 18, 2022 · 4 comments
Open

Every time an e-book is opened a new data base row is created #373

aTom3333 opened this issue Apr 18, 2022 · 4 comments

Comments

@aTom3333
Copy link

Let's say I have an e-book file test.epub and my bookworm.db is empty.

  • I open my e-book -> works as expected ✔️
  • Looking at the db, a row has been created in the BOOK_LIBRARY_TABLE6 table, the BOOK_LOCATION corresponds to my e-book and most other fields are empty ✔️
  • I close bookworm (let's say on page 3)
  • The db row has been updated to be populated with the e-book metadata ✔️
  • I reopen the same file -> works as expected, I'm back at page 3 ✔️
  • In the db, a second row has been created with the same BOOK_LOCATION, probably not the expected behavior ❌
  • I navigate to page 5 and close bookworm
  • The first db row is correctly updated to have BOOK_LAST_READ_PAGE_NUMBER equals to 5 ✔️ but the second row is still there ans still mostly empty ❌
  • I reopen again the same e-book -> I'm back at page 5 but when trying to navigate I get an error message telling me there is a navigation error and from then on, I can't navigate or read this file anymore (even after closing and reopening again). ❌ I suspect this is related to the presence of this second row in the database (BTW, opening the file for a 3rd time, created a 3rd as well, mostly empty too)
    If I manually go into the database and delete those unwanted empty rows, I'm back to being able to read my e-book
@babluboy
Copy link
Owner

Thanks for the detailed issue. As far as I remember, a new row is created if the filepath+file name combination does not exist. So will check why a second row is getting created

@aTom3333
Copy link
Author

If it helps, the way I am using the application is by double clicking on my epub file (which does com.github.babluboy.bookworm /absolute/path/to/my.epub) and not by browsing my library using bookworm.

The callstack at the point where the row is added in the database is:

#0  bookworm_app_db_addBookToDataBase (aBook=) at ../../../../../../Programmation/Vala/bookworm/src/database.vala:337
#1  0x00005555555ce594 in bookworm_app_library_addBookToLibrary (aBook=) at ../../../../../../Programmation/Vala/bookworm/src/library.vala:590
#2  0x00005555555ce1d1 in bookworm_app_library_addBooksToLibrary_co (_data_=0x555555f3e010) at ../../../../../../Programmation/Vala/bookworm/src/library.vala:569
#3  0x00005555555cd5ad in bookworm_app_library_addBooksToLibrary (_callback_=0x0, _user_data_=0x0) at ../../../../../../Programmation/Vala/bookworm/src/library.vala:21
#4  0x0000555555570913 in bookworm_app_bookworm_real_activate (base=0x55555585a120) at ../../../../../../Programmation/Vala/bookworm/src/bookworm.vala:274
#5  0x00007ffff7258969 in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff7271339 in g_signal_emit_valist () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff727155f in g_signal_emit () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x000055555556fad9 in bookworm_app_bookworm_real_command_line (base=0x55555585a120, command_line=0x555555b3f7a0) at ../../../../../../Programmation/Vala/bookworm/src/bookworm.vala:145
#9  0x00007ffff7322efd in  () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#10 0x00007ffff7258969 in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff727069b in g_signal_emit_valist () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00007ffff727155f in g_signal_emit () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#13 0x00007ffff737f563 in  () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#14 0x00007ffff7381f59 in  () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#15 0x00007ffff73820de in g_application_run () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
#16 0x000055555556f738 in _vala_main (args=0x7fffffffe6a8, args_length1=2) at ../../../../../../Programmation/Vala/bookworm/src/main.vala:38
#17 0x000055555556f760 in main (argc=2, argv=0x7fffffffe6a8) at ../../../../../../Programmation/Vala/bookworm/src/main.vala:20

@aTom3333
Copy link
Author

Indeed, the issue doesn't occur when I simply run bookworm alone (equivalent to running com.github.babluboy.bookworm). In that case my last e-book is opened and no new row is created. So it seems the way I used bookworm isn't supported

@babluboy
Copy link
Owner

Yes, based on the HIG of elementary OS and also Apple, specific software should be used to explore, open and work with concerned file types.

however the way you used bookworm is also something which can be adapted. While I had some code to deal with double click of e-books to add them to bookworm, I can improve it to do some checks to first check if the ebook is already added and handle the scenario by opening the book at the required content

Will keep this issue open to improve the behaviour and avoid the issue you have highlighted

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

No branches or pull requests

2 participants