mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 07:20:12 +01:00
Prevent opened board re-migrating and reloading every 5 seconds.
Thanks to xet7 !
This commit is contained in:
parent
ef7771febb
commit
4987a95d8e
3 changed files with 59 additions and 3 deletions
|
|
@ -646,6 +646,23 @@ class MigrationManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix boards that are stuck in migration loop
|
||||
*/
|
||||
fixStuckBoards() {
|
||||
try {
|
||||
Meteor.call('boardMigration.fixStuckBoards', (error, result) => {
|
||||
if (error) {
|
||||
console.error('Failed to fix stuck boards:', error);
|
||||
} else {
|
||||
console.log('Fix stuck boards result:', result);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error fixing stuck boards:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start migration process using cron system
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -314,10 +314,11 @@ class BoardMigrationDetector {
|
|||
*/
|
||||
markBoardAsMigrated(boardId, migrationType) {
|
||||
try {
|
||||
// Update migration markers
|
||||
// Update migration markers and version
|
||||
const updateQuery = {};
|
||||
updateQuery[`migrationMarkers.${migrationType}Migrated`] = true;
|
||||
updateQuery['migrationMarkers.lastMigration'] = new Date();
|
||||
updateQuery['migrationVersion'] = 1; // Set migration version to prevent re-migration
|
||||
|
||||
Boards.update(boardId, { $set: updateQuery });
|
||||
|
||||
|
|
@ -392,5 +393,42 @@ Meteor.methods({
|
|||
}
|
||||
|
||||
return boardMigrationDetector.startBoardMigration(boardId);
|
||||
},
|
||||
|
||||
'boardMigration.fixStuckBoards'() {
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('not-authorized');
|
||||
}
|
||||
|
||||
// Find boards that have migration markers but no migrationVersion
|
||||
const stuckBoards = Boards.find({
|
||||
'migrationMarkers.fullMigrationCompleted': true,
|
||||
$or: [
|
||||
{ migrationVersion: { $exists: false } },
|
||||
{ migrationVersion: { $lt: 1 } }
|
||||
]
|
||||
}).fetch();
|
||||
|
||||
let fixedCount = 0;
|
||||
stuckBoards.forEach(board => {
|
||||
try {
|
||||
Boards.update(board._id, {
|
||||
$set: {
|
||||
migrationVersion: 1,
|
||||
'migrationMarkers.lastMigration': new Date()
|
||||
}
|
||||
});
|
||||
fixedCount++;
|
||||
console.log(`Fixed stuck board: ${board._id} (${board.title})`);
|
||||
} catch (error) {
|
||||
console.error(`Error fixing board ${board._id}:`, error);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
message: `Fixed ${fixedCount} stuck boards`,
|
||||
fixedCount,
|
||||
totalStuck: stuckBoards.length
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -607,11 +607,12 @@ class CronMigrationManager {
|
|||
*/
|
||||
markBoardAsMigrated(boardId, migrationType) {
|
||||
try {
|
||||
// Update board with migration markers
|
||||
// Update board with migration markers and version
|
||||
const updateQuery = {
|
||||
'migrationMarkers.fullMigrationCompleted': true,
|
||||
'migrationMarkers.lastMigration': new Date(),
|
||||
'migrationMarkers.migrationType': migrationType
|
||||
'migrationMarkers.migrationType': migrationType,
|
||||
'migrationVersion': 1 // Set migration version to prevent re-migration
|
||||
};
|
||||
|
||||
// Update the board document
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue