store images in notes, basic structure

This commit is contained in:
azivner
2018-11-08 10:11:00 +01:00
parent 5f427e37fe
commit d0d2a7fe47
24 changed files with 11589 additions and 141 deletions

View File

@@ -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');