mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fixes for image download
This commit is contained in:
		
							
								
								
									
										18
									
								
								.idea/dataSources.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								.idea/dataSources.xml
									
									
									
										generated
									
									
									
								
							| @@ -1,25 +1,11 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project version="4"> | ||||
|   <component name="DataSourceManagerImpl" format="xml" multifile-model="true"> | ||||
|     <data-source source="LOCAL" name="document.db" uuid="a2c75661-f9e2-478f-a69f-6a9409e69997"> | ||||
|     <data-source source="LOCAL" name="SQLite - document.db" uuid="d0fd879f-1e1d-4d5c-9c21-0e5cf9ab2976"> | ||||
|       <driver-ref>sqlite.xerial</driver-ref> | ||||
|       <synchronize>true</synchronize> | ||||
|       <jdbc-driver>org.sqlite.JDBC</jdbc-driver> | ||||
|       <jdbc-url>jdbc:sqlite:$USER_HOME$/trilium-data/document.db</jdbc-url> | ||||
|     </data-source> | ||||
|     <data-source source="LOCAL" name="document" uuid="066dc5f4-4097-429e-8cf1-3adc0a9d648a"> | ||||
|       <driver-ref>sqlite.xerial</driver-ref> | ||||
|       <synchronize>true</synchronize> | ||||
|       <jdbc-driver>org.sqlite.JDBC</jdbc-driver> | ||||
|       <jdbc-url>jdbc:sqlite:$PROJECT_DIR$/dist/trilium linux x64/trilium-data/document.db</jdbc-url> | ||||
|       <libraries> | ||||
|         <library> | ||||
|           <url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/xerial-sqlite-license.txt</url> | ||||
|         </library> | ||||
|         <library> | ||||
|           <url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/sqlite-jdbc-3.16.1.jar</url> | ||||
|         </library> | ||||
|       </libraries> | ||||
|       <jdbc-url>jdbc:sqlite:$PROJECT_DIR$/../trilium-data/document.db</jdbc-url> | ||||
|     </data-source> | ||||
|   </component> | ||||
| </project> | ||||
| @@ -19,6 +19,7 @@ const BUILTIN_ATTRIBUTES = [ | ||||
|     { type: 'label', name: 'appTheme' }, | ||||
|     { type: 'label', name: 'hidePromotedAttributes' }, | ||||
|     { type: 'label', name: 'readOnly' }, | ||||
|     { type: 'label', name: 'autoReadOnlyDisabled' }, | ||||
|     { type: 'label', name: 'cssClass' }, | ||||
|     { type: 'label', name: 'iconClass' }, | ||||
|     { type: 'label', name: 'keyboardShortcut' }, | ||||
|   | ||||
| @@ -293,15 +293,11 @@ async function downloadImages(noteId, content) { | ||||
|         if (!url.includes('api/images/') | ||||
|             // this is and exception for the web clipper's "imageId" | ||||
|             && (url.length !== 20 || url.toLowerCase().startsWith('http'))) { | ||||
|             if (url in downloadImagePromises) { | ||||
|                 // download is already in progress | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             if (url in imageUrlToNoteIdMapping) { | ||||
|                 const imageNote = await repository.getNote(imageUrlToNoteIdMapping[url]); | ||||
|  | ||||
|                 if (imageNote || imageNote.isDeleted) { | ||||
|                 if (!imageNote || imageNote.isDeleted) { | ||||
|                     delete imageUrlToNoteIdMapping[url]; | ||||
|                 } | ||||
|                 else { | ||||
| @@ -322,6 +318,11 @@ async function downloadImages(noteId, content) { | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             if (url in downloadImagePromises) { | ||||
|                 // download is already in progress | ||||
|                 continue; | ||||
|             } | ||||
|  | ||||
|             // this is done asynchronously, it would be too slow to wait for the download | ||||
|             // given that save can be triggered very often | ||||
|             downloadImagePromises[url] = downloadImage(noteId, url); | ||||
| @@ -338,6 +339,7 @@ async function downloadImages(noteId, content) { | ||||
|             // are downloaded and the IMG references are not updated. For this occassion we have this code | ||||
|             // which upon the download of all the images will update the note if the links have not been fixed before | ||||
|  | ||||
|             await sql.transactional(async () => { | ||||
|                 const imageNotes = await repository.getNotes(Object.values(imageUrlToNoteIdMapping)); | ||||
|  | ||||
|                 const origNote = await repository.getNote(noteId); | ||||
| @@ -360,6 +362,7 @@ async function downloadImages(noteId, content) { | ||||
|  | ||||
|                     console.log(`Fixed the image links for note ${noteId} to the offline saved.`); | ||||
|                 } | ||||
|             }); | ||||
|         }, 5000); | ||||
|     }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user