cfangmeier / tuijam

A fancy TUI client for Google Play Music
MIT License
129 stars 9 forks source link

History and queue from old versions are not read after 0.4.0 update #35

Closed t1meshift closed 5 years ago

t1meshift commented 5 years ago

The problem is in the serializer. A queue and a history from the new version start with \80]q\00ctuijam.tuijam, while old versions' ones start with \80]q\00(c__main__.

I have a temporary solution: run sed -i 's/__main__/tuijam.tuijam/' ~/.config/tuijam/*.p before running the new version. If it is already running, kill the player without Ctrl-C shortcut (kill -9 $(pgrep tuijam), for example). That's it. pickle can unpickle these files using custom unpickler, as seen there: https://stackoverflow.com/a/53327348

I doubt that my way of migrations is correct, but at least it works :)

cfangmeier commented 5 years ago

I think rather than cluttering up the code with some method to detect a pre 0.4.0 set of files and convert them, it's better to just document this in the README and point people to your workaround. What do you think?

t1meshift commented 5 years ago

Sure, why not? Also, about code decluttering... How about splitting the code on modules since its structure is ready for that?

cfangmeier commented 5 years ago

Yeah, the code has grown quite a lot since the hacky little script I had originally. I agree moving things into separate modules is the way to go. I'll find some time to work on that over the next few days.

cfangmeier commented 5 years ago

Ok, so there is a refactoring-in-progress in the modularize branch, and I decided to just ditch pickle and instead save the items as JSON. This, of course, would imply the need for a second migration to go from 0.4.0 format to JSON.

I think the simplest solution is to put a disclaimer in the readme that the queue and history format is in flux and not to depend on it being consistent between versions. Since these files or rather ephemeral anyway, I don't think it will be a big problem.