mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
store images in notes, basic structure
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
const build = require('./build');
|
||||
const packageJson = require('../../package');
|
||||
|
||||
const APP_DB_VERSION = 114;
|
||||
const SYNC_VERSION = 1;
|
||||
const APP_DB_VERSION = 115;
|
||||
const SYNC_VERSION = 2;
|
||||
|
||||
module.exports = {
|
||||
appVersion: packageJson.version,
|
||||
|
||||
@@ -209,7 +209,13 @@ async function runAllChecks() {
|
||||
FROM
|
||||
notes
|
||||
WHERE
|
||||
type != 'text' AND type != 'code' AND type != 'render' AND type != 'file' AND type != 'search' AND type != 'relation-map'`,
|
||||
type != 'text'
|
||||
AND type != 'code'
|
||||
AND type != 'render'
|
||||
AND type != 'file'
|
||||
AND type != 'image'
|
||||
AND type != 'search'
|
||||
AND type != 'relation-map'`,
|
||||
"Note has invalid type", errorList);
|
||||
|
||||
await runCheck(`
|
||||
|
||||
@@ -247,7 +247,8 @@ const primaryKeys = {
|
||||
"note_images": "noteImageId",
|
||||
"api_tokens": "apiTokenId",
|
||||
"options": "name",
|
||||
"attributes": "attributeId"
|
||||
"attributes": "attributeId",
|
||||
"links": "linkId"
|
||||
};
|
||||
|
||||
async function getEntityRow(entityName, entityId) {
|
||||
|
||||
@@ -28,6 +28,10 @@ async function addRecentNoteSync(branchId, sourceId) {
|
||||
await addEntitySync("recent_notes", branchId, sourceId);
|
||||
}
|
||||
|
||||
async function addLinkSync(linkId, sourceId) {
|
||||
await addEntitySync("links", linkId, sourceId);
|
||||
}
|
||||
|
||||
async function addImageSync(imageId, sourceId) {
|
||||
await addEntitySync("images", imageId, sourceId);
|
||||
}
|
||||
@@ -91,10 +95,9 @@ async function fillAllSyncRows() {
|
||||
await fillSyncRows("branches", "branchId");
|
||||
await fillSyncRows("note_revisions", "noteRevisionId");
|
||||
await fillSyncRows("recent_notes", "branchId");
|
||||
await fillSyncRows("images", "imageId");
|
||||
await fillSyncRows("note_images", "noteImageId");
|
||||
await fillSyncRows("attributes", "attributeId");
|
||||
await fillSyncRows("api_tokens", "apiTokenId");
|
||||
await fillSyncRows("links", "linkId");
|
||||
await fillSyncRows("options", "name", 'isSynced = 1');
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ async function updateEntity(sync, entity, sourceId) {
|
||||
else if (entityName === 'recent_notes') {
|
||||
await updateRecentNotes(entity, sourceId);
|
||||
}
|
||||
else if (entityName === 'links') {
|
||||
await updateLink(entity, sourceId);
|
||||
}
|
||||
else if (entityName === 'images') {
|
||||
await updateImage(entity, sourceId);
|
||||
}
|
||||
@@ -139,6 +142,20 @@ async function updateRecentNotes(entity, sourceId) {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateLink(entity, sourceId) {
|
||||
const origLink = await sql.getRow("SELECT * FROM links WHERE linkId = ?", [entity.linkId]);
|
||||
|
||||
if (!origLink || origLink.dateModified <= entity.dateModified) {
|
||||
await sql.transactional(async () => {
|
||||
await sql.replace("links", entity);
|
||||
|
||||
await syncTableService.addLinkSync(entity.linkId, sourceId);
|
||||
});
|
||||
|
||||
log.info("Update/sync link " + entity.linkId);
|
||||
}
|
||||
}
|
||||
|
||||
async function updateImage(entity, sourceId) {
|
||||
if (entity.data !== null) {
|
||||
entity.data = Buffer.from(entity.data, 'base64');
|
||||
|
||||
Reference in New Issue
Block a user