PasTim wrote: 
> Thanks for that.  Very interesting.  Do you think there is there any way
> of intervening after LMS has deleted library.db and manually resetting
> the contents before any damage is done to related data?

I don’t  think this can be fixed without changing the Multi Library
plugin code.

If the schema_clear.sql script is used to clear the database its strange
that we see a problem at all because then the Multi Library tables
shouldn’t be cleared even during a full rescan.
https://github.com/Logitech/slimserver/blob/public/8.2/SQL/SQLite/schema_clear.sql
>From my memory the whole library.db was deleted during a full rescan but
I can’t  find this in the code at the moment so it might have changed
since Multi Library plugin was implemented. If library.db is deleted I’d
expect the library ids to always start over from 1 after a full rescan.
It’s also possible to reset it manually:
https://www.designcise.com/web/tutorial/how-to-reset-autoincrement-number-sequence-in-sqlite
However, please remember that the hash order is still unpredictable if
you have more than a single library, so resetting the AUTOINCREMENT
column isn’t really a solution.

The solution as I tried to indicate in my previous post is:
> 
> 
> A solution to this really need to store an id in either the library
> configuration file or in the prefs file of each library and replace the
> AUTOINCREMENT column with a manually updated integer and make sure to
> take the value from prefs/library configuration when creating the row in
> multilibrary_libraries table, which happens here:
> https://github.com/erland/lms-multilibrary/blob/28d437d83235aceaac6e47b389727d46488de139/src/Plugin.pm#L352
> It’s probably easiest to store Id in prefs because then it can be
> completely handled in initDatabaseLibrary function and doesn’t have to
> affect other parts of the code.
> 
Basically:
- Redefine multilibrary_libraries.id to not be an AUTOINCREMENT column.
You should instead in the code manually calculate the next free id when
a new library is created and its row is inserted in this table.
max(id)+1 should work.
- Make sure to save the library id in the prefs file for each library
created
- When initializing a library in the table, take the id from the prefs
file
Should be possible to implement the whole thing in initDatabaseLibrary
function in MultiLibrary/Plugin.pm

A logic like this will make sure the ids stays the same as long as you
don’t delete the prefs file or renames the library definition file.



Erland Isaksson ('My homepage' (http://erland.isaksson.info))
Developer of 'many plugins/applets'
(https://wiki.slimdevices.com/index.php/User_Erland.html)
*Starting with LMS 8.0 I no longer support my plugins/applets* ('see
here for more information'
(https://forums.slimdevices.com/showthread.php?49483-Announce-New-versions-of-erlands-plugins&p=998836&viewfull=1#post998836)
)
------------------------------------------------------------------------
erland's Profile: http://forums.slimdevices.com/member.php?userid=3124
View this thread: http://forums.slimdevices.com/showthread.php?t=49483

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to