attribute sync fixes

This commit is contained in:
azivner 2018-01-13 23:33:09 -05:00
parent 359ff58be8
commit 45a92313d5
2 changed files with 14 additions and 3 deletions

View File

@ -80,7 +80,18 @@ async function getHashes() {
date_modified,
date_created
FROM images
ORDER BY image_id`))
ORDER BY image_id`)),
attributes: getHash(await sql.getAll(`
SELECT
attribute_id,
note_id
name,
value
date_modified,
date_created
FROM attributes
ORDER BY attribute_id`))
};
const elapseTimeMs = new Date().getTime() - startTime.getTime();

View File

@ -124,11 +124,11 @@ async function updateNoteImage(entity, sourceId) {
}
async function updateAttribute(entity, sourceId) {
const origAttribute = await sql.getFirst("SELECT * FROM attribute WHERE attribute_id = ?", [entity.attribute_id]);
const origAttribute = await sql.getFirst("SELECT * FROM attributes WHERE attribute_id = ?", [entity.attribute_id]);
if (!origAttribute || origAttribute.date_modified <= entity.date_modified) {
await sql.doInTransaction(async () => {
await sql.replace("attribute", entity);
await sql.replace("attributes", entity);
await sync_table.addAttributeSync(entity.attribute_id, sourceId);
});