Improved sync

pull/41/head
Laurent Cozic 2017-10-26 23:56:32 +02:00
parent bd8926958f
commit 0b80859055
4 changed files with 21 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{
"name": "joplin",
"version": "0.10.55",
"version": "0.10.57",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -3892,7 +3892,7 @@
"boom": "4.3.1",
"cryptiles": "3.1.2",
"hoek": "4.2.0",
"sntp": "2.0.2"
"sntp": "2.1.0"
}
},
"hoek": {
@ -4896,9 +4896,9 @@
}
},
"sntp": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-2.0.2.tgz",
"integrity": "sha1-UGQRDwr4X3z9t9a2ekACjOUrSys=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz",
"integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==",
"requires": {
"hoek": "4.2.0"
}
@ -5771,9 +5771,9 @@
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"tkwidgets": {
"version": "0.5.14",
"resolved": "https://registry.npmjs.org/tkwidgets/-/tkwidgets-0.5.14.tgz",
"integrity": "sha512-VCb6phgm8X684mv3m3+Ylz06XwG3iNSuGgFUyxV+lcz8VU2ZTnXXeitsxCujY5t4EFL7n+Qob33+izt+S84YgA==",
"version": "0.5.15",
"resolved": "https://registry.npmjs.org/tkwidgets/-/tkwidgets-0.5.15.tgz",
"integrity": "sha512-fzxINXVK4f+Rp2fSkVoUVcF097sNQMqCrdCtiqj0Pel1aP1xU1+nQL4HGjqqrUHM30TsOQVyDu38/S70KPdsHg==",
"requires": {
"chalk": "2.3.0",
"node-emoji": "git+https://github.com/laurent22/node-emoji.git#9fa01eac463e94dde1316ef8c53089eeef4973b5",

View File

@ -18,7 +18,7 @@
],
"owner": "Laurent Cozic"
},
"version": "0.10.55",
"version": "0.10.57",
"bin": {
"joplin": "./main.js"
},
@ -55,7 +55,7 @@
"string-to-stream": "^1.1.0",
"strip-ansi": "^4.0.0",
"tcp-port-used": "^0.1.2",
"tkwidgets": "^0.5.3",
"tkwidgets": "^0.5.15",
"uuid": "^3.0.1",
"word-wrap": "^1.2.3",
"yargs-parser": "^7.0.0"

View File

@ -79,6 +79,8 @@ class FileApiDriverLocal {
}
async delta(path, options) {
const itemIds = await options.allItemIdsHandler();
try {
let items = await fs.readdir(path);
let output = [];
@ -89,11 +91,11 @@ class FileApiDriverLocal {
output.push(stat);
}
if (!Array.isArray(options.itemIds)) throw new Error('Delta API not supported - local IDs must be provided');
if (!Array.isArray(itemIds)) throw new Error('Delta API not supported - local IDs must be provided');
let deletedItems = [];
for (let i = 0; i < options.itemIds.length; i++) {
const itemId = options.itemIds[i];
for (let i = 0; i < itemIds.length; i++) {
const itemId = itemIds[i];
let found = false;
for (let j = 0; j < output.length; j++) {
const item = output[j];

View File

@ -358,14 +358,15 @@ class Synchronizer {
while (true) {
if (this.cancelling()) break;
let allIds = null;
if (!this.api().supportsDelta()) {
allIds = await BaseItem.syncedItemIds(syncTargetId);
}
// let allIds = null;
// if (!this.api().supportsDelta()) {
// allIds = await BaseItem.syncedItemIds(syncTargetId);
// }
let listResult = await this.api().delta('', {
context: context,
itemIds: allIds,
// itemIds: allIds,
allItemIdsHandler: async () => { return BaseItem.syncedItemIds(syncTargetId); }
});
let remotes = listResult.items;