Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more logs to migrations and create a settings backup #1036

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

gauthier-th
Copy link
Collaborator

@gauthier-th gauthier-th commented Oct 19, 2024

Description

Screenshot (if UI-related)

To-Dos

  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Issues Fixed or Closed

  • Fixes #XXXX

@gauthier-th gauthier-th marked this pull request as ready for review October 19, 2024 21:09
Fallenbagel
Fallenbagel previously approved these changes Oct 19, 2024
server/lib/settings/migrator.ts Fixed Show fixed Hide fixed
server/lib/settings/migrator.ts Fixed Show fixed Hide fixed
server/lib/settings/migrator.ts Outdated Show resolved Hide resolved
server/lib/settings/migrator.ts Outdated Show resolved Hide resolved
server/lib/settings/migrator.ts Show resolved Hide resolved
server/lib/settings/migrator.ts Outdated Show resolved Hide resolved
server/lib/settings/migrator.ts Outdated Show resolved Hide resolved
server/lib/settings/migrator.ts Show resolved Hide resolved
Comment on lines 62 to 65
} else if (oldBackup) {
// no migration occured
// we save the old backup (to avoid settings.json and settings.old.json being the same)
fs.writeFileSync(BACKUP_PATH, oldBackup.toString());
Copy link
Owner

Choose a reason for hiding this comment

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

Once again, fs.promises.

Suggested change
} else if (oldBackup) {
// no migration occured
// we save the old backup (to avoid settings.json and settings.old.json being the same)
fs.writeFileSync(BACKUP_PATH, oldBackup.toString());
await fs.promises.writeFile(SETTINGS_PATH, JSON.stringify(migrated, null, 2));

Would it be better to parse this json with type safety?

const fileSaved = JSON.parse(await fs.promises.readFile(SETTINGS_PATH, 'utf-8')) as AllSettings;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could but I don't really see the point of this since this variable is only used once to be compared after being stringified.

@Fallenbagel
Copy link
Owner

We can ignore the broken cypress test. That is because trending api is broken and it's currently showing people instead of media

server/lib/settings/migrator.ts Fixed Show fixed Hide fixed
server/lib/settings/migrator.ts Fixed Show fixed Hide fixed
server/lib/settings/migrator.ts Fixed Show resolved Hide resolved
@gauthier-th
Copy link
Collaborator Author

Fixed some of your comments.

@gauthier-th gauthier-th merged commit 326001c into develop Oct 24, 2024
8 checks passed
@gauthier-th gauthier-th deleted the more-migration-logs branch October 24, 2024 16:12
bonswouar pushed a commit to bonswouar/jellyseerr that referenced this pull request Nov 10, 2024
…nbagel#1036)

* feat: add more logs to migrations and create a settings backup

* fix: avoid backup to be replaced at next startup

* fix: resolve review comments

* fix: try to fix CodeQL warnings
@Fallenbagel
Copy link
Owner

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants