mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/stable'
This commit is contained in:
		
						commit
						402e29d6dc
					
				| @ -213,9 +213,13 @@ export default class Entrypoints extends Component { | |||||||
|         } else if (note.mime.endsWith("env=backend")) { |         } else if (note.mime.endsWith("env=backend")) { | ||||||
|             await server.post('script/run/' + note.noteId); |             await server.post('script/run/' + note.noteId); | ||||||
|         } else if (note.mime === 'text/x-sqlite;schema=trilium') { |         } else if (note.mime === 'text/x-sqlite;schema=trilium') { | ||||||
|             const {results} = await server.post("sql/execute/" + note.noteId); |             const resp = await server.post("sql/execute/" + note.noteId); | ||||||
| 
 | 
 | ||||||
|             await appContext.triggerEvent('sqlQueryResults', {ntxId: ntxId, results: results}); |             if (!resp.success) { | ||||||
|  |                 alert("Error occurred while executing SQL query: " + resp.message); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             await appContext.triggerEvent('sqlQueryResults', {ntxId: ntxId, results: resp.results}); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         toastService.showMessage("Note executed"); |         toastService.showMessage("Note executed"); | ||||||
|  | |||||||
| @ -258,7 +258,8 @@ class ConsistencyChecks { | |||||||
|                              FROM branches |                              FROM branches | ||||||
|                              WHERE noteId = ? |                              WHERE noteId = ? | ||||||
|                                and parentNoteId = ? |                                and parentNoteId = ? | ||||||
|                                and isDeleted = 0`, [noteId, parentNoteId]);
 |                                and isDeleted = 0 | ||||||
|  |                              ORDER BY utcDateCreated`, [noteId, parentNoteId]);
 | ||||||
| 
 | 
 | ||||||
|                     const branches = branchIds.map(branchId => becca.getBranch(branchId)); |                     const branches = branchIds.map(branchId => becca.getBranch(branchId)); | ||||||
| 
 | 
 | ||||||
| @ -537,6 +538,27 @@ class ConsistencyChecks { | |||||||
|                         logError(`Unrecognized entity change id=${id}, entityName=${entityName}, entityId=${entityId}`); |                         logError(`Unrecognized entity change id=${id}, entityName=${entityName}, entityId=${entityId}`); | ||||||
|                     } |                     } | ||||||
|                 }); |                 }); | ||||||
|  | 
 | ||||||
|  |         this.findAndFixIssues(` | ||||||
|  |             SELECT  | ||||||
|  |               id, entityId | ||||||
|  |             FROM  | ||||||
|  |               entity_changes  | ||||||
|  |               JOIN ${entityName} ON entityId = ${key}  | ||||||
|  |             WHERE | ||||||
|  |               entity_changes.isErased = 1 | ||||||
|  |               AND entity_changes.entityName = '${entityName}'`,
 | ||||||
|  |             ({id, entityId}) => { | ||||||
|  |                 if (this.autoFix) { | ||||||
|  |                     sql.execute(`DELETE FROM ${entityName} WHERE ${key} = ?`, [entityId]); | ||||||
|  | 
 | ||||||
|  |                     this.reloadNeeded = true; | ||||||
|  | 
 | ||||||
|  |                     logFix(`Erasing entityName=${entityName}, entityId=${entityId} since entity change id=${id} has it as erased.`); | ||||||
|  |                 } else { | ||||||
|  |                     logError(`Entity change id=${id} has entityName=${entityName}, entityId=${entityId} as erased, but it's not.`); | ||||||
|  |                 } | ||||||
|  |             }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     findEntityChangeIssues() { |     findEntityChangeIssues() { | ||||||
| @ -603,14 +625,14 @@ class ConsistencyChecks { | |||||||
|         this.fixedIssues = false; |         this.fixedIssues = false; | ||||||
|         this.reloadNeeded = false; |         this.reloadNeeded = false; | ||||||
| 
 | 
 | ||||||
|  |         this.findEntityChangeIssues(); | ||||||
|  | 
 | ||||||
|         this.findBrokenReferenceIssues(); |         this.findBrokenReferenceIssues(); | ||||||
| 
 | 
 | ||||||
|         this.findExistencyIssues(); |         this.findExistencyIssues(); | ||||||
| 
 | 
 | ||||||
|         this.findLogicIssues(); |         this.findLogicIssues(); | ||||||
| 
 | 
 | ||||||
|         this.findEntityChangeIssues(); |  | ||||||
| 
 |  | ||||||
|         this.findWronglyNamedAttributes(); |         this.findWronglyNamedAttributes(); | ||||||
| 
 | 
 | ||||||
|         this.findSyncIssues(); |         this.findSyncIssues(); | ||||||
|  | |||||||
| @ -733,6 +733,8 @@ function eraseAttributes(attributeIdsToErase) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function eraseDeletedEntities(eraseEntitiesAfterTimeInSeconds = null) { | function eraseDeletedEntities(eraseEntitiesAfterTimeInSeconds = null) { | ||||||
|  |     // this is important also so that the erased entity changes are sent to the connected clients
 | ||||||
|  |     sql.transactional(() => { | ||||||
|         if (eraseEntitiesAfterTimeInSeconds === null) { |         if (eraseEntitiesAfterTimeInSeconds === null) { | ||||||
|             eraseEntitiesAfterTimeInSeconds = optionService.getOptionInt('eraseEntitiesAfterTimeInSeconds'); |             eraseEntitiesAfterTimeInSeconds = optionService.getOptionInt('eraseEntitiesAfterTimeInSeconds'); | ||||||
|         } |         } | ||||||
| @ -750,6 +752,7 @@ function eraseDeletedEntities(eraseEntitiesAfterTimeInSeconds = null) { | |||||||
|         const attributeIdsToErase = sql.getColumn("SELECT attributeId FROM attributes WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateTimeStr(cutoffDate)]); |         const attributeIdsToErase = sql.getColumn("SELECT attributeId FROM attributes WHERE isDeleted = 1 AND utcDateModified <= ?", [dateUtils.utcDateTimeStr(cutoffDate)]); | ||||||
| 
 | 
 | ||||||
|         eraseAttributes(attributeIdsToErase); |         eraseAttributes(attributeIdsToErase); | ||||||
|  |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function eraseNotesWithDeleteId(deleteId) { | function eraseNotesWithDeleteId(deleteId) { | ||||||
|  | |||||||
| @ -34,6 +34,7 @@ function getHiddenRoot() { | |||||||
| 
 | 
 | ||||||
|     if (!hidden) { |     if (!hidden) { | ||||||
|         hidden = noteService.createNewNote({ |         hidden = noteService.createNewNote({ | ||||||
|  |             branchId: 'hidden', | ||||||
|             noteId: 'hidden', |             noteId: 'hidden', | ||||||
|             title: 'hidden', |             title: 'hidden', | ||||||
|             type: 'text', |             type: 'text', | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam