mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-29 02:28:57 +01:00 
			
		
		
		
	run consistency checks on demand
This commit is contained in:
		
							parent
							
								
									ee15db0ae1
								
							
						
					
					
						commit
						dce54c7af3
					
				| @ -13,6 +13,10 @@ const TPL = ` | ||||
| <br/> | ||||
| <br/> | ||||
| 
 | ||||
| <h4>Consistency checks</h4> | ||||
| 
 | ||||
| <button id="find-and-fix-consistency-issues-button" class="btn">Find and fix consistency issues</button><br/><br/> | ||||
| 
 | ||||
| <h4>Debugging</h4> | ||||
| 
 | ||||
| <button id="anonymize-button" class="btn">Save anonymized database</button><br/><br/> | ||||
| @ -33,9 +37,8 @@ export default class AdvancedOptions { | ||||
|         this.$forceFullSyncButton = $("#force-full-sync-button"); | ||||
|         this.$fillSyncRowsButton = $("#fill-sync-rows-button"); | ||||
|         this.$anonymizeButton = $("#anonymize-button"); | ||||
|         this.$cleanupSoftDeletedButton = $("#cleanup-soft-deleted-items-button"); | ||||
|         this.$cleanupUnusedImagesButton = $("#cleanup-unused-images-button"); | ||||
|         this.$vacuumDatabaseButton = $("#vacuum-database-button"); | ||||
|         this.$findAndFixConsistencyIssuesButton = $("#find-and-fix-consistency-issues-button"); | ||||
| 
 | ||||
|         this.$forceFullSyncButton.on('click', async () => { | ||||
|             await server.post('sync/force-full-sync'); | ||||
| @ -55,26 +58,16 @@ export default class AdvancedOptions { | ||||
|             toastService.showMessage("Created anonymized database"); | ||||
|         }); | ||||
| 
 | ||||
|         this.$cleanupSoftDeletedButton.on('click', async () => { | ||||
|             if (confirm("Do you really want to clean up soft-deleted items?")) { | ||||
|                 await server.post('cleanup/cleanup-soft-deleted-items'); | ||||
| 
 | ||||
|                 toastService.showMessage("Soft deleted items have been cleaned up"); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         this.$cleanupUnusedImagesButton.on('click', async () => { | ||||
|             if (confirm("Do you really want to clean up unused images?")) { | ||||
|                 await server.post('cleanup/cleanup-unused-images'); | ||||
| 
 | ||||
|                 toastService.showMessage("Unused images have been cleaned up"); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         this.$vacuumDatabaseButton.on('click', async () => { | ||||
|             await server.post('cleanup/vacuum-database'); | ||||
| 
 | ||||
|             toastService.showMessage("Database has been vacuumed"); | ||||
|         }); | ||||
| 
 | ||||
|         this.$findAndFixConsistencyIssuesButton.on('click', async () => { | ||||
|             await server.post('cleanup/find-and-fix-consistency-issues'); | ||||
| 
 | ||||
|             toastService.showMessage("Consistency issues should be fixed."); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| @ -2,6 +2,7 @@ | ||||
| 
 | ||||
| const sql = require('../../services/sql'); | ||||
| const log = require('../../services/log'); | ||||
| const consistencyChecksService = require('../../services/consistency_checks'); | ||||
| 
 | ||||
| async function vacuumDatabase() { | ||||
|     await sql.execute("VACUUM"); | ||||
| @ -9,6 +10,11 @@ async function vacuumDatabase() { | ||||
|     log.info("Database has been vacuumed."); | ||||
| } | ||||
| 
 | ||||
| async function findAndFixConsistencyIssues() { | ||||
|     await consistencyChecksService.runOnDemandChecks(true); | ||||
| } | ||||
| 
 | ||||
| module.exports = { | ||||
|     vacuumDatabase | ||||
|     vacuumDatabase, | ||||
|     findAndFixConsistencyIssues | ||||
| }; | ||||
| @ -215,10 +215,11 @@ function register(app) { | ||||
|     apiRoute(POST, '/api/sql/execute', sqlRoute.execute); | ||||
|     apiRoute(POST, '/api/anonymization/anonymize', anonymizationRoute.anonymize); | ||||
| 
 | ||||
|     apiRoute(POST, '/api/cleanup/cleanup-unused-images', cleanupRoute.cleanupUnusedImages); | ||||
|     // VACUUM requires execution outside of transaction
 | ||||
|     route(POST, '/api/cleanup/vacuum-database', [auth.checkApiAuthOrElectron, csrfMiddleware], cleanupRoute.vacuumDatabase, apiResultHandler, false); | ||||
| 
 | ||||
|     route(POST, '/api/cleanup/find-and-fix-consistency-issues', [auth.checkApiAuthOrElectron, csrfMiddleware], cleanupRoute.findAndFixConsistencyIssues, apiResultHandler, false); | ||||
| 
 | ||||
|     apiRoute(POST, '/api/script/exec', scriptRoute.exec); | ||||
|     apiRoute(POST, '/api/script/run/:noteId', scriptRoute.run); | ||||
|     apiRoute(GET, '/api/script/startup', scriptRoute.getStartupBundles); | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam