lv2 / lilv

LV2 host library
ISC License
37 stars 20 forks source link

Recreating LV2 presets deletes sym-linked files #37

Closed x42 closed 3 years ago

x42 commented 4 years ago

In Ardour, saving a preset first deletes the current presets, and then re-creates it.

lilv_world_unload_resource();
lilv_state_delete();
// [..]
lilv_state_new_from_instance();
lilv_state_save();

This worked fine before https://github.com/lv2/lilv/commit/c9a54e019d54cbccfff742d5c5662ff021b187a9, however recent liblilv unlinks all the external resource in lilv_state_delete(), and for some reason they are not re-created.

Since creating presets works correctly, it looks as if the files are still assumed to be mapped and hence the symlinks not re-created.

Related to https://github.com/sadko4u/lsp-plugins/issues/119#issuecomment-649048899

sadko4u commented 4 years ago

Also may be related: https://github.com/sadko4u/lsp-plugins/issues/120

drobilla commented 4 years ago

I don't think the linked commit (which only removes fewer files) is the root of this, or that it's related to the above LSP issue.

Deleting state then saving it again like this can not work, because plugins can save files when their state is saved (which happens at lilv_state_new_from_instance() or similar, not lilv_state_save(). So, what Ardour is doing is (potentially) deleting state (real, actual files that the plugin may be using, not just links to external things), then trying to save that state again. That saved state is garbage because files are completely gone.

It may also be true that linked things get weird, but it doesn't matter. I'm not yet sure what the correct way to do this is yet, though.

drobilla commented 3 years ago

Closing this as a PEBKAC, since, as explained above, there is no way lilv could possibly make what Ardour was doing work. It only happened to work before, sometimes, if plugins didn't save files.

Please open any follow-up state bugs clearly, for example:

From a clean state, I do this and this, and get this:

/whatever/state.lv2/somefile => sometarget

and I expect this:

/whatever/state.lv2/somethingelse => someothertarget