#98, sync setup now doesn't copy the whole DB file, but sets up minimal database and starts off sync

This commit is contained in:
azivner
2018-07-23 21:15:32 +02:00
parent a06618d851
commit 1fe7c62f5a
12 changed files with 185 additions and 100 deletions

View File

@@ -7,7 +7,7 @@ const sql = require('../../services/sql');
const optionService = require('../../services/options');
const contentHashService = require('../../services/content_hash');
const log = require('../../services/log');
const DOCUMENT_PATH = require('../../services/data_dir').DOCUMENT_PATH;
const repository = require('../../services/repository');
async function testSync() {
try {
@@ -23,6 +23,10 @@ async function testSync() {
}
}
async function getStats() {
return syncService.stats;
}
async function checkSync() {
return {
hashes: await contentHashService.getHashes(),
@@ -75,7 +79,10 @@ async function getChanged(req) {
const syncs = await sql.getRows("SELECT * FROM sync WHERE id > ? LIMIT 1000", [lastSyncId]);
return await syncService.getSyncRecords(syncs);
return {
syncs: await syncService.getSyncRecords(syncs),
maxSyncId: await sql.getValue('SELECT MAX(id) FROM sync')
};
}
async function update(req) {
@@ -87,10 +94,13 @@ async function update(req) {
}
}
async function getDocument(req, resp) {
log.info("Serving document.");
async function getDocument() {
log.info("Serving document options.");
resp.sendFile(DOCUMENT_PATH);
return [
await repository.getOption('documentId'),
await repository.getOption('documentSecret')
];
}
module.exports = {
@@ -102,5 +112,6 @@ module.exports = {
forceNoteSync,
getChanged,
update,
getDocument
getDocument,
getStats
};