Skip to content

Conversation

@absidue
Copy link
Member

@absidue absidue commented Feb 11, 2024

Fix playlists DB import and export not using the actual DB format

Pull Request Type

  • 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

  1. Create multiple playlists
  2. Close FreeTube
  3. Backup your playlists database file (https://docs.freetubeapp.io/usage/data-location/, yarn dev uses a folder called Electron instead)
  4. Open FreeTube again and click Remove All Playlists in the Privacy Settings
  5. Import your backed up playlists database
  6. Check that your playlists show up correctly in the UI
  7. Export your playlists
  8. Remove All Playlists in the Privacy Settings again
  9. Import the playlists database that you just exported
  10. 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)

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Feb 11, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) February 11, 2024 13:02
@PikachuEXE
Copy link
Collaborator

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

d21a7f1#diff-3d237cfb3b1c9b7a1d14cc731643319d4e50982c43202b626bc6de4d25376269R1225

So this is a breaking change for all previous FT versions

@absidue
Copy link
Member Author

absidue commented Feb 12, 2024

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).

@absidue absidue added PR: WIP and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels Feb 12, 2024
@absidue absidue added PR: waiting for review For PRs that are complete, tested, and ready for review and removed PR: WIP labels Feb 16, 2024
@absidue
Copy link
Member Author

absidue commented Feb 16, 2024

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.

Copy link
Collaborator

@PikachuEXE PikachuEXE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Export: tested both export formats with text editor
Import: tested 3 formats, 2 above, 1 with older format but with json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a dump q based on the convo im reading but still going to ask it, is this expected?

VirtualBoxVM_lJFemLAl9o.mp4

@PikachuEXE
Copy link
Collaborator

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dismiss my previous q😬

@FreeTubeBot FreeTubeBot merged commit 3c26450 into FreeTubeApp:development Mar 7, 2024
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Mar 7, 2024
@absidue absidue deleted the fix-playlists-import-export branch March 7, 2024 15:52
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Mar 13, 2024
* development: (28 commits)
  Fix handling of video published date in video lists (FreeTubeApp#4752)
  Translated using Weblate (Dutch)
  Translated using Weblate (Chinese (Simplified))
  Bump lefthook from 1.6.4 to 1.6.5 (FreeTubeApp#4758)
  Bump marked from 12.0.0 to 12.0.1 (FreeTubeApp#4757)
  Bump electron from 29.1.0 to 29.1.1 (FreeTubeApp#4756)
  Translated using Weblate (Portuguese)
  Translated using Weblate (Portuguese (Brazil))
  Improve touch controls for dash quality selector (FreeTubeApp#4750)
  Translated using Weblate (Serbian)
  Translated using Weblate (Spanish)
  Translated using Weblate (French)
  Translated using Weblate (German)
  Translated using Weblate (Estonian)
  Translated using Weblate (Polish)
  Translated using Weblate (Basque)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Portuguese (Brazil))
  Fix playlists database import and export not using the actual database format (FreeTubeApp#4664)
  ...

# Conflicts:
#	src/renderer/views/Search/Search.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants