mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-30 12:19:13 -04:00
Disable cleanup by default and show errors in admin area
This commit is contained in:
parent
593d1021b6
commit
3330ed8d1b
6 changed files with 53 additions and 1 deletions
|
@ -254,6 +254,13 @@ exports.socketio = (hookName: string, {io}: any) => {
|
|||
})
|
||||
|
||||
socket.on('cleanupPadRevisions', async (padId: string) => {
|
||||
if (!settings.cleanup.enabled) {
|
||||
socket.emit('results:cleanupPadRevisions', {
|
||||
error: 'Cleanup disabled. Enable cleanup in settings.json: cleanup.enabled => true',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const padExists = await padManager.doesPadExists(padId);
|
||||
if (padExists) {
|
||||
logger.info(`Cleanup pad revisions: ${padId}`);
|
||||
|
@ -265,9 +272,16 @@ exports.socketio = (hookName: string, {io}: any) => {
|
|||
keepRevisions: settings.cleanup.keepRevisions,
|
||||
});
|
||||
logger.info('successful cleaned up pad: ', padId)
|
||||
} else {
|
||||
socket.emit('results:cleanupPadRevisions', {
|
||||
error: 'Error cleaning up pad',
|
||||
});
|
||||
}
|
||||
} catch (err: any) {
|
||||
logger.error(`Error in pad ${padId}: ${err.stack || err}`);
|
||||
socket.emit('results:cleanupPadRevisions', {
|
||||
error: err.toString(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ exports.deleteRevisions = async (padId: string, keepRevisions: number): Promise<
|
|||
|
||||
logger.debug('Initial pad is valid')
|
||||
|
||||
if (pad.head < keepRevisions) {
|
||||
if (pad.head <= keepRevisions) {
|
||||
logger.debug('Pad has not enough revisions')
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -384,6 +384,7 @@ exports.showSettingsInAdminPage = true;
|
|||
* Settings for cleanup of pads
|
||||
*/
|
||||
exports.cleanup = {
|
||||
enabled: false,
|
||||
keepRevisions: 100,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue