Merge branch 'master' into stable

This commit is contained in:
azivner 2017-12-12 23:57:40 -05:00
commit 2fa57b79fd
5 changed files with 18 additions and 8 deletions

View File

@ -42,6 +42,9 @@ const messaging = (function() {
changesToPushCountEl.html(message.changesToPushCount); changesToPushCountEl.html(message.changesToPushCount);
} }
else if (message.type === 'sync-hash-check-failed') {
showError("Sync check failed!", 60000);
}
} }
function connectWebSocket() { function connectWebSocket() {

View File

@ -78,7 +78,8 @@ const noteTree = (function() {
} }
function getNodesByNoteId(noteId) { function getNodesByNoteId(noteId) {
return getTree().getNodesByRef(noteId); const list = getTree().getNodesByRef(noteId);
return list ? list : []; // if no nodes with this refKey are found, fancy tree returns null
} }
function setPrefix(noteTreeId, prefix) { function setPrefix(noteTreeId, prefix) {
@ -614,6 +615,8 @@ const noteTree = (function() {
setParentChildRelation(result.note_tree_id, parentNoteId, result.note_id); setParentChildRelation(result.note_tree_id, parentNoteId, result.note_id);
notesTreeMap[result.note_tree_id] = result;
noteIdToTitle[result.note_id] = newNoteName; noteIdToTitle[result.note_id] = newNoteName;
noteEditor.newNoteCreated(); noteEditor.newNoteCreated();

View File

@ -17,7 +17,7 @@ function showMessage(message) {
}); });
} }
function showError(message) { function showError(message, delay = 10000) {
console.log("error: ", message); console.log("error: ", message);
$.notify({ $.notify({
@ -26,7 +26,7 @@ function showError(message) {
},{ },{
// settings // settings
type: 'danger', type: 'danger',
delay: 10000 delay: delay
}); });
} }

View File

@ -70,8 +70,6 @@ async function migrate() {
await options.setOption("db_version", mig.dbVersion); await options.setOption("db_version", mig.dbVersion);
}); });
sql.setDbReadyAsResolved();
log.info("Migration to version " + mig.dbVersion + " has been successful."); log.info("Migration to version " + mig.dbVersion + " has been successful.");
mig['success'] = true; mig['success'] = true;
@ -86,6 +84,10 @@ async function migrate() {
} }
} }
if (sql.isDbUpToDate()) {
sql.setDbReadyAsResolved();
}
return migrations; return migrations;
} }

View File

@ -4,7 +4,6 @@ const log = require('./log');
const rp = require('request-promise'); const rp = require('request-promise');
const sql = require('./sql'); const sql = require('./sql');
const options = require('./options'); const options = require('./options');
const migration = require('./migration');
const utils = require('./utils'); const utils = require('./utils');
const config = require('./config'); const config = require('./config');
const source_id = require('./source_id'); const source_id = require('./source_id');
@ -14,6 +13,7 @@ const content_hash = require('./content_hash');
const event_log = require('./event_log'); const event_log = require('./event_log');
const fs = require('fs'); const fs = require('fs');
const app_info = require('./app_info'); const app_info = require('./app_info');
const messaging = require('./messaging');
const SYNC_SERVER = config['Sync']['syncServerHost']; const SYNC_SERVER = config['Sync']['syncServerHost'];
const isSyncSetup = !!SYNC_SERVER; const isSyncSetup = !!SYNC_SERVER;
@ -123,7 +123,7 @@ async function pullSync(syncContext) {
for (const sync of syncRows) { for (const sync of syncRows) {
if (source_id.isLocalSourceId(sync.source_id)) { if (source_id.isLocalSourceId(sync.source_id)) {
log.info("Skipping " + sync.entity_name + " " + sync.entity_id + " because it has local source id."); log.info("Skipping pull " + sync.entity_name + " " + sync.entity_id + " because it has local source id.");
await setLastSyncedPull(sync.id); await setLastSyncedPull(sync.id);
@ -188,7 +188,7 @@ async function pushSync(syncContext) {
} }
if (sync.source_id === syncContext.sourceId) { if (sync.source_id === syncContext.sourceId) {
log.info("Skipping sync " + sync.entity_name + " " + sync.entity_id + " because it originates from sync target"); log.info("Skipping push " + sync.entity_name + " " + sync.entity_id + " because it originates from sync target");
} }
else { else {
await readAndPushEntity(sync, syncContext); await readAndPushEntity(sync, syncContext);
@ -271,6 +271,8 @@ async function checkContentHash(syncContext) {
log.info("Content hash check PASSED with value: " + localContentHash); log.info("Content hash check PASSED with value: " + localContentHash);
} }
else { else {
await messaging.sendMessage({type: 'sync-hash-check-failed'});
await event_log.addEvent("Content hash check FAILED. Local is " + localContentHash + ", remote is " + resp.content_hash); await event_log.addEvent("Content hash check FAILED. Local is " + localContentHash + ", remote is " + resp.content_hash);
} }
} }