mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 86b1410952 | ||
|  | 29eb88bac3 | ||
|  | 31b4186e17 | ||
|  | bde9e825c8 | ||
|  | 0e8285a7e4 | 
							
								
								
									
										10
									
								
								bin/build.sh
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								bin/build.sh
									
									
									
									
									
								
							| @@ -4,9 +4,11 @@ echo "Deleting dist" | ||||
|  | ||||
| rm -r dist/* | ||||
|  | ||||
| cp -r ../trilium-node-binaries/sqlite/* node_modules/sqlite3/lib/binding/ | ||||
|  | ||||
| cp -r ../trilium-node-binaries/scrypt/* node_modules/scrypt/bin/ | ||||
| cp -r bin/deps/sqlite/* node_modules/sqlite3/lib/binding/ | ||||
| cp -r bin/deps/scrypt/* node_modules/scrypt/bin/ | ||||
| cp -r bin/deps/image/cjpeg.exe node_modules/mozjpeg/vendor/ | ||||
| cp -r bin/deps/image/pngquant.exe node_modules/pngquant-bin/vendor/ | ||||
| cp -r bin/deps/image/gifsicle.exe node_modules/giflossy/vendor/ | ||||
|  | ||||
| ./node_modules/.bin/electron-rebuild --arch=ia32 | ||||
|  | ||||
| @@ -19,4 +21,4 @@ cp -r ../trilium-node-binaries/scrypt/* node_modules/scrypt/bin/ | ||||
| ./node_modules/.bin/electron-packager . --out=dist --platform=win32 --arch=x64 --overwrite | ||||
|  | ||||
| # can't copy this before the packaging because the same file name is used for both linux and windows build | ||||
| cp ../trilium-node-binaries/scrypt.node ./dist/trilium-win32-x64/resources/app/node_modules/scrypt/build/Release/ | ||||
| cp bin/deps/scrypt/win32-x64-57/scrypt.node ./dist/trilium-win32-x64/resources/app/node_modules/scrypt/build/Release/ | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								bin/deps/image/cjpeg.exe
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/deps/image/cjpeg.exe
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/deps/image/gifsicle.exe
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/deps/image/gifsicle.exe
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/deps/image/pngquant.exe
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/deps/image/pngquant.exe
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/deps/scrypt/win32-x64-57/scrypt.node
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/deps/scrypt/win32-x64-57/scrypt.node
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/deps/sqlite/electron-v1.8-win32-x64/node_sqlite3.node
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/deps/sqlite/electron-v1.8-win32-x64/node_sqlite3.node
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/deps/sqlite/node-v57-win32-x64/node_sqlite3.node
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/deps/sqlite/node-v57-win32-x64/node_sqlite3.node
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								db/image-deleted.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								db/image-deleted.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 4.4 KiB | 
| @@ -83,3 +83,28 @@ CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` ( | ||||
| CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` ( | ||||
|   `date_modified_to` | ||||
| ); | ||||
| CREATE TABLE images | ||||
| ( | ||||
|   image_id TEXT PRIMARY KEY NOT NULL, | ||||
|   format TEXT NOT NULL, | ||||
|   checksum TEXT NOT NULL, | ||||
|   name TEXT NOT NULL, | ||||
|   data BLOB, | ||||
|   is_deleted INT NOT NULL DEFAULT 0, | ||||
|   date_modified TEXT NOT NULL, | ||||
|   date_created TEXT NOT NULL | ||||
| ); | ||||
|  | ||||
| CREATE TABLE notes_image | ||||
| ( | ||||
|   note_image_id TEXT PRIMARY KEY NOT NULL, | ||||
|   note_id TEXT NOT NULL, | ||||
|   image_id TEXT NOT NULL, | ||||
|   is_deleted INT NOT NULL DEFAULT 0, | ||||
|   date_modified TEXT NOT NULL, | ||||
|   date_created TEXT NOT NULL | ||||
| ); | ||||
|  | ||||
| CREATE INDEX notes_image_note_id_index ON notes_image (note_id); | ||||
| CREATE INDEX notes_image_image_id_index ON notes_image (image_id); | ||||
| CREATE INDEX notes_image_note_id_image_id_index ON notes_image (note_id, image_id); | ||||
| @@ -1,7 +1,7 @@ | ||||
| { | ||||
|   "name": "trilium", | ||||
|   "description": "Trilium Notes", | ||||
|   "version": "0.3.0", | ||||
|   "version": "0.3.1", | ||||
|   "license": "AGPL-3.0-only", | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|   | ||||
| @@ -157,6 +157,7 @@ settings.addModule((async function () { | ||||
|     const fillSyncRowsButton = $("#fill-sync-rows-button"); | ||||
|     const anonymizeButton = $("#anonymize-button"); | ||||
|     const cleanupSoftDeletedButton = $("#cleanup-soft-deleted-items-button"); | ||||
|     const cleanupUnusedImagesButton = $("#cleanup-unused-images-button"); | ||||
|     const vacuumDatabaseButton = $("#vacuum-database-button"); | ||||
|  | ||||
|     forceFullSyncButton.click(async () => { | ||||
| @@ -186,6 +187,14 @@ settings.addModule((async function () { | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     cleanupUnusedImagesButton.click(async () => { | ||||
|         if (confirm("Do you really want to clean up unused images?")) { | ||||
|             await server.post('cleanup/cleanup-unused-images'); | ||||
|  | ||||
|             showMessage("Unused images have been cleaned up"); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     vacuumDatabaseButton.click(async () => { | ||||
|         await server.post('cleanup/vacuum-database'); | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								public/libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								public/libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -22,6 +22,10 @@ router.post('/cleanup-soft-deleted-items', auth.checkApiAuth, wrap(async (req, r | ||||
|  | ||||
|         await sql.execute("DELETE FROM notes_tree WHERE is_deleted = 1"); | ||||
|  | ||||
|         await sql.execute("DELETE FROM notes_image WHERE is_deleted = 1"); | ||||
|  | ||||
|         await sql.execute("DELETE FROM images WHERE is_deleted = 1"); | ||||
|  | ||||
|         await sql.execute("DELETE FROM notes WHERE is_deleted = 1"); | ||||
|  | ||||
|         await sql.execute("DELETE FROM recent_notes"); | ||||
| @@ -37,6 +41,33 @@ router.post('/cleanup-soft-deleted-items', auth.checkApiAuth, wrap(async (req, r | ||||
|     res.send({}); | ||||
| })); | ||||
|  | ||||
| router.post('/cleanup-unused-images', auth.checkApiAuth, wrap(async (req, res, next) => { | ||||
|     const sourceId = req.headers.source_id; | ||||
|  | ||||
|     await sql.doInTransaction(async () => { | ||||
|         const unusedImageIds = await sql.getFirstColumn(` | ||||
|           SELECT images.image_id  | ||||
|           FROM images  | ||||
|             LEFT JOIN notes_image ON notes_image.image_id = images.image_id AND notes_image.is_deleted = 0 | ||||
|           WHERE | ||||
|             images.is_deleted = 0 | ||||
|             AND notes_image.note_image_id IS NULL`); | ||||
|  | ||||
|         const now = utils.nowDate(); | ||||
|  | ||||
|         for (const imageId of unusedImageIds) { | ||||
|             log.info(`Deleting unused image: ${imageId}`); | ||||
|  | ||||
|             await sql.execute("UPDATE images SET is_deleted = 1, data = null, date_modified = ? WHERE image_id = ?", | ||||
|                 [now, imageId]); | ||||
|  | ||||
|             await sync_table.addImageSync(imageId, sourceId); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     res.send({}); | ||||
| })); | ||||
|  | ||||
| router.post('/vacuum-database', auth.checkApiAuth, wrap(async (req, res, next) => { | ||||
|     await sql.execute("VACUUM"); | ||||
|  | ||||
|   | ||||
| @@ -15,6 +15,8 @@ const jimp = require('jimp'); | ||||
| const imageType = require('image-type'); | ||||
| const sanitizeFilename = require('sanitize-filename'); | ||||
| const wrap = require('express-promise-wrap').wrap; | ||||
| const RESOURCE_DIR = require('../../services/resource_dir').RESOURCE_DIR; | ||||
| const fs = require('fs'); | ||||
|  | ||||
| router.get('/:imageId/:filename', auth.checkApiAuthOrElectron, wrap(async (req, res, next) => { | ||||
|     const image = await sql.getFirst("SELECT * FROM images WHERE image_id = ?", [req.params.imageId]); | ||||
| @@ -22,6 +24,10 @@ router.get('/:imageId/:filename', auth.checkApiAuthOrElectron, wrap(async (req, | ||||
|     if (!image) { | ||||
|         return res.status(404).send({}); | ||||
|     } | ||||
|     else if (image.data === null) { | ||||
|         res.set('Content-Type', 'image/png'); | ||||
|         return res.send(fs.readFileSync(RESOURCE_DIR + '/db/image-deleted.png')); | ||||
|     } | ||||
|  | ||||
|     res.set('Content-Type', 'image/' + image.format); | ||||
|  | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| module.exports = { build_date:"2018-01-07T10:04:46-05:00", build_revision: "488e657cc43fab879662a6da23b5a69dd7591b06" }; | ||||
| module.exports = { build_date:"2018-01-07T21:56:39-05:00", build_revision: "29eb88bac3bbc1db17bb4ed75f9b8bfe16333967" }; | ||||
|   | ||||
| @@ -187,6 +187,17 @@ async function runAllChecks() { | ||||
|             notes_image.note_image_id IS NULL`, | ||||
|         "Image with no note relation", errorList); | ||||
|  | ||||
|     await runCheck(` | ||||
|           SELECT  | ||||
|             notes_image.note_image_id | ||||
|           FROM  | ||||
|             notes_image | ||||
|             JOIN images USING(image_id) | ||||
|           WHERE  | ||||
|             notes_image.is_deleted = 0 | ||||
|             AND images.is_deleted = 1`, | ||||
|         "Note image is not deleted while image is deleted for note_image_id", errorList); | ||||
|  | ||||
|     await runSyncRowChecks("notes", "note_id", errorList); | ||||
|     await runSyncRowChecks("notes_history", "note_history_id", errorList); | ||||
|     await runSyncRowChecks("notes_tree", "note_tree_id", errorList); | ||||
|   | ||||
| @@ -248,12 +248,24 @@ | ||||
|           <p>This action will create a new copy of the database and anonymise it (remove all note content and leave only structure and metadata) | ||||
|             for sharing online for debugging purposes without fear of leaking your personal data.</p> | ||||
|  | ||||
|           <h4>Cleanup</h4> | ||||
|           <h4>Image cleanup</h4> | ||||
|  | ||||
|           <button id="cleanup-soft-deleted-items-button" class="btn btn-danger btn-sm">Permanently cleanup soft-deleted items</button> (should be executed in all synced instances) | ||||
|           <p>This will remove all image data of images not used in any current version of note from the database (metadata will remain). | ||||
|  | ||||
|           <br/> | ||||
|           <br/> | ||||
|             This means that some images can disappear from note history.</p> | ||||
|  | ||||
|           <button id="cleanup-unused-images-button" class="btn btn-warning btn-sm">Permanently cleanup unused images</button> | ||||
|  | ||||
|           <h4>Soft-delete cleanup</h4> | ||||
|  | ||||
|           <p>This deletes all soft deleted rows from the database. This change isn't synced and should be done manually on all instances. | ||||
|             <strong>Use this only if you really know what you're doing.</strong></p> | ||||
|  | ||||
|           <button id="cleanup-soft-deleted-items-button" class="btn btn-danger btn-sm">Permanently cleanup soft-deleted items</button> | ||||
|  | ||||
|           <h4>Vacuum database</h4> | ||||
|  | ||||
|           <p>This will rebuild database which will typically result in smaller database file. No data will be actually changed.</p> | ||||
|  | ||||
|           <button id="vacuum-database-button" class="btn btn-sm">Vacuum database</button> | ||||
|         </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user