wold5 / calibre-pocketbook-tools

A Calibre UI plugin that offers a collection of tools for PocketBook e-readers.
15 stars 1 forks source link

Convert (back) “self.profiles” to list if not already a list #1

Closed romainsc closed 2 years ago

romainsc commented 2 years ago

HI,

After looking for the reason of the export of highlights was not working on my pocketbook color, I found out the profile management was not working as expected when there is only one profile. I am proposing this fix, according the following reasons:

  1. As sqlite_execute_query remplace the returned value by the item of the list if the sql request returned only one data,
  2. and as changing this behavior could lead to unexpected impact in other part of the code,
  3. and as it is clear that self.profiles is expected to be a list and nothing else,

I choose to convert back to list if the profiles is not a list after asking for the profile list at device connection and not in getprofilespaths() `function.

I hope this change will help others.

Regards,

wold5 commented 2 years ago

Hi, thank you for reporting this.

You're correct on the source. This was overlooked as my PB has multiple profiles. Now the real cause was (me) trying to be smart with the return value of sqlite_execute_query()... with this being the result ;)

While your proposed solution is good, I would propose fixing this at the source and let sqlite_execute_query() always return a list. The ([0]) subsetting additions are less elegant than your fix, but it's more consistent overall. A new version with these changes will be released soon. I'll credit you.

wold5 commented 2 years ago

Closing (forgotten). A fixed version was released begin September.

BTW, AFAIK stock units don't use these profiles, until a user toggles the profile settings. Then, the /system/ 'root' profile is converted to the 'default' profile.