mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-03 15:32:30 +02:00
All: Fixed: Local items were no longer being deleted via sync. Also fixed Nextcloud sync target.
This commit is contained in:
parent
8f4060999f
commit
c46d123503
@ -291,23 +291,30 @@ describe('Synchronizer', function() {
|
||||
}));
|
||||
|
||||
it('should delete local notes', asyncTest(async () => {
|
||||
// For these tests we pass the context around for each user. This is to make sure that the "deletedItemsProcessed"
|
||||
// property of the basicDelta() function is cleared properly at the end of a sync operation. If it is not cleared
|
||||
// it means items will no longer be deleted locally via sync.
|
||||
|
||||
let folder1 = await Folder.save({ title: "folder1" });
|
||||
let note1 = await Note.save({ title: "un", parent_id: folder1.id });
|
||||
await synchronizer().start();
|
||||
let note2 = await Note.save({ title: "deux", parent_id: folder1.id });
|
||||
let context1 = await synchronizer().start();
|
||||
|
||||
await switchClient(2);
|
||||
|
||||
await synchronizer().start();
|
||||
let context2 = await synchronizer().start();
|
||||
await Note.delete(note1.id);
|
||||
await synchronizer().start();
|
||||
context2 = await synchronizer().start({ context: context2 });
|
||||
|
||||
await switchClient(1);
|
||||
|
||||
await synchronizer().start();
|
||||
context1 = await synchronizer().start({ context: context1 });
|
||||
let items = await allItems();
|
||||
expect(items.length).toBe(1);
|
||||
expect(items.length).toBe(2);
|
||||
let deletedItems = await BaseItem.deletedItems(syncTargetId());
|
||||
expect(deletedItems.length).toBe(0);
|
||||
await Note.delete(note2.id);
|
||||
context1 = await synchronizer().start({ context: context1 });
|
||||
}));
|
||||
|
||||
it('should delete remote folder', asyncTest(async () => {
|
||||
|
@ -236,7 +236,7 @@ class WebDavApi {
|
||||
// The "solution", an ugly one, is to send a purposely invalid string as eTag, which will bypass the If-None-Match check - Seafile
|
||||
// finds out that no resource has this ID and simply sends the requested data.
|
||||
// Also add a random value to make sure the eTag is unique for each call.
|
||||
if (['GET', 'HEAD'].indexOf(method) < 0) headers['If-None-Match'] = 'JoplinIgnore-' + Math.floor(Math.random() * 100000);
|
||||
//if (['GET', 'HEAD'].indexOf(method) < 0) headers['If-None-Match'] = 'JoplinIgnore-' + Math.floor(Math.random() * 100000);
|
||||
|
||||
const fetchOptions = {};
|
||||
fetchOptions.headers = headers;
|
||||
@ -294,7 +294,7 @@ class WebDavApi {
|
||||
if (json && json['d:error']) {
|
||||
const code = json['d:error']['s:exception'] ? json['d:error']['s:exception'].join(' ') : response.status;
|
||||
const message = json['d:error']['s:message'] ? json['d:error']['s:message'].join("\n") : 'Unknown error 1';
|
||||
throw newError(message, code);
|
||||
throw newError(message + '(Exception ' + code + ')', response.status);
|
||||
}
|
||||
|
||||
throw newError('Unknown error 2', response.status);
|
||||
|
@ -304,7 +304,13 @@ async function basicDelta(path, getDirStatFn, options) {
|
||||
newContext.deletedItemsProcessed = true;
|
||||
|
||||
const hasMore = output.length >= outputLimit;
|
||||
if (!hasMore) newContext.statsCache = null;
|
||||
|
||||
if (!hasMore) {
|
||||
// Clear temporary info from context. It's especially important to remove deletedItemsProcessed
|
||||
// so that they are processed again on the next sync.
|
||||
newContext.statsCache = null;
|
||||
delete newContext.deletedItemsProcessed;
|
||||
}
|
||||
|
||||
return {
|
||||
hasMore: hasMore,
|
||||
|
Loading…
x
Reference in New Issue
Block a user