Fix playlists database import and export not using the actual database format
Fix playlists DB import and export not using the actual DB format
Pull Request Type
- [x] Bugfix
Description
Currently the playlists export generates a JSON array with the playlists and the playlists import expects said JSON array, however that doesn't match the actual playlists database format, so you can't import a real playlists database file. If we exported it as JSON file that would be fine, but we explicitly label it as a database file and expect a database file to be picked during the import.
This pull request changes the import and export to match the real database format (each playlist is a JSON object on it's own line, with a final new line at the end of the file), so that we are consistent across the board. It still supports importing the old array format for the sake of backwards compatibility.
While yes this is technically a breaking change compared to previous nightly builds, it's not a breaking change compared to the previous (0.19.1) release. It corrects incorrect behaviour and people cannot expect stability across nightly builds, as they are by definition development/bleeding edge builds, which we've never recommended normal users use for every day use.
Testing
- Create multiple playlists
- Close FreeTube
- Backup your playlists database file (https://docs.freetubeapp.io/usage/data-location/,
yarn devuses a folder calledElectroninstead) - Open FreeTube again and click
Remove All Playlistsin thePrivacy Settings - Import your backed up playlists database
- Check that your playlists show up correctly in the UI
- Export your playlists
-
Remove All Playlistsin thePrivacy Settingsagain - Import the playlists database that you just exported
- Check that your playlists show up correctly in the UI
If both the original import (a real database written by nedb) and the secondary one (the database created by the export) were successful (no errors and playlists show up), this pull request works as expected.
Desktop
- OS: Windows
- OS Version: 10
- FreeTube version: 30248d6 (nightlies)
I checked the file for history & the logic at 0.19.1 Using JSON as input/output is done since the day playlist import/export was introduced
https://github.com/FreeTubeApp/FreeTube/commit/d21a7f1c245c92df8e3eadb0a401fee9daf36848#diff-3d237cfb3b1c9b7a1d14cc731643319d4e50982c43202b626bc6de4d25376269R1225
So this is a breaking change for all previous FT versions
I'll add back support for the old format in the import, for the sake of backwards compatibility so that you can import both a real FreeTube database and the JSON array format (if you want to export your playlists for 0.19.1 or below you need to enable the backwards compatibility switch before exporting anyway, so the new export doesn't need support for both).
It now supports importing the proper database format and the old array format. The export is only for the proper database format, anyone that wants to export their playlists to 0.19.1 or below or to nightlies before the playlists PR, needs to use the Export Playlists For Older FreeTube Versions switch anyway, which isn't affected by this pull request.
That makes this only a breaking change for the nightlies between this pull request and the playlists pull request, which is completely fine.
Probably a dump q based on the convo im reading but still going to ask it, is this expected?
If you are expecting default generated playlists, they are only generated after app restart (or new window open?) Otherwise not so sure what are you referring to in the video about expected or not.