mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	fix preserving original sourceId after running script notes, fixes #2224
This commit is contained in:
		
							
								
								
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1344,9 +1344,9 @@ | ||||
|       "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" | ||||
|     }, | ||||
|     "axios": { | ||||
|       "version": "0.22.0", | ||||
|       "resolved": "https://registry.npmjs.org/axios/-/axios-0.22.0.tgz", | ||||
|       "integrity": "sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==", | ||||
|       "version": "0.23.0", | ||||
|       "resolved": "https://registry.npmjs.org/axios/-/axios-0.23.0.tgz", | ||||
|       "integrity": "sha512-NmvAE4i0YAv5cKq8zlDoPd1VLKAqX5oLuZKs8xkJa4qi6RGn0uhCYFjWtHHC9EM/MwOwYWOs53W+V0aqEXq1sg==", | ||||
|       "requires": { | ||||
|         "follow-redirects": "^1.14.4" | ||||
|       } | ||||
|   | ||||
| @@ -30,11 +30,12 @@ function executeBundle(bundle, apiParams = {}) { | ||||
|         apiParams.startNote = bundle.note; | ||||
|     } | ||||
|  | ||||
|     const originalSourceId = cls.get('sourceId'); | ||||
|  | ||||
|     cls.set('sourceId', 'script'); | ||||
|  | ||||
|     // last \r\n is necessary if script contains line comment on its last line | ||||
|     const script = "function() {\r\n" + bundle.script + "\r\n}"; | ||||
|  | ||||
|     const ctx = new ScriptContext(bundle.allNotes, apiParams); | ||||
|  | ||||
|     try { | ||||
| @@ -45,6 +46,9 @@ function executeBundle(bundle, apiParams = {}) { | ||||
|  | ||||
|         throw e; | ||||
|     } | ||||
|     finally { | ||||
|         cls.set('sourceId', originalSourceId); | ||||
|     } | ||||
| } | ||||
|  | ||||
| /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user