From 9e154d08575ea1450f5dd320d5fac91f061b983b Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 1 Jun 2023 11:42:14 +0200 Subject: [PATCH] Merge pull request #13298 from overleaf/msm-hotfix-3_5_7 CE/SP Hotfix 3.5.7 GitOrigin-RevId: 4f530530cd351c2780b86caba00cb9f7516253d1 --- server-ce/hotfix/3.5.7/Dockerfile | 5 +++ server-ce/hotfix/3.5.7/force_clean_fix.patch | 40 ++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 server-ce/hotfix/3.5.7/Dockerfile create mode 100644 server-ce/hotfix/3.5.7/force_clean_fix.patch diff --git a/server-ce/hotfix/3.5.7/Dockerfile b/server-ce/hotfix/3.5.7/Dockerfile new file mode 100644 index 0000000000..fed79042da --- /dev/null +++ b/server-ce/hotfix/3.5.7/Dockerfile @@ -0,0 +1,5 @@ +FROM sharelatex/sharelatex:3.5.6 + +# Patch: clean up history id on `migrate_history.js --force-clean` +COPY force_clean_fix.patch . +RUN patch -p0 < force_clean_fix.patch diff --git a/server-ce/hotfix/3.5.7/force_clean_fix.patch b/server-ce/hotfix/3.5.7/force_clean_fix.patch new file mode 100644 index 0000000000..40cbf2a29a --- /dev/null +++ b/server-ce/hotfix/3.5.7/force_clean_fix.patch @@ -0,0 +1,40 @@ +--- services/web/modules/history-migration/app/src/HistoryUpgradeHelper.js ++++ services/web/modules/history-migration/app/src/HistoryUpgradeHelper.js +@@ -115,6 +115,11 @@ async function upgradeProject(project, options) { + const projectId = project._id + // delete any existing history stored in the mongo backend + await HistoryManager.promises.deleteProject(projectId, projectId) ++ // unset overleaf.history.id to prevent the migration script from failing on checks ++ await db.projects.updateOne( ++ { _id: projectId }, ++ { $unset: { 'overleaf.history.id': '' } } ++ ) + } catch (err) { + // failed to delete existing history, but we can try to continue + } +--- services/web/scripts/history/migrate_history.js ++++ services/web/scripts/history/migrate_history.js +@@ -147,7 +147,7 @@ async function migrateProjects(projectsToMigrate) { + } + // send log output for each migration to a file + const output = fs.createWriteStream(argv.output, { flags: 'a' }) +- console.log(`Writing log output to ${argv.output}`) ++ console.log(`Writing log output to ${process.cwd()}/${argv.output}`) + const logger = new console.Console({ stdout: output }) + function logJson(obj) { + logger.log(JSON.stringify(obj)) +@@ -253,8 +253,12 @@ async function main() { + console.log('Projects migrated: ', projectsMigrated) + console.log('Projects failed: ', projectsFailed) + if (projectsFailed > 0) { +- console.log(`Log output written to ${argv.output}`) +- console.log('Please check the log for errors.') ++ console.log('------------------------------------------------------') ++ console.log(`Log output written to ${process.cwd()}/${argv.output}`) ++ console.log( ++ 'Please check the log for errors. Attach the content of the file when contacting support.' ++ ) ++ console.log('------------------------------------------------------') + } + if (INTERRUPT) { + console.log('Migration interrupted, please run again to continue.')