1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Desktop, Cli, Mobile, Server: Optimise synchronisation by making delta call return whole items

This commit is contained in:
Laurent Cozic
2023-12-23 13:13:50 +00:00
parent 1fcfa9c591
commit 5341501d53
9 changed files with 116 additions and 28 deletions

View File

@@ -43,6 +43,14 @@ export interface PaginatedList {
context: any;
}
// Tells whether the delta call is going to include the items themselves or
// just the metadata (which is the default). If the items are included it
// means less http request and faster processing.
export const getSupportsDeltaWithItems = (deltaResponse: PaginatedList) => {
if (!deltaResponse.items.length) return false;
return 'jopItem' in deltaResponse.items[0];
};
function requestCanBeRepeated(error: any) {
const errorCode = typeof error === 'object' && error.code ? error.code : null;
@@ -139,13 +147,6 @@ class FileApi {
return !!this.driver().supportsLocks;
}
// Tells whether the delta call is going to include the items themselves or
// just the metadata (which is the default). If the items are included it
// means less http request and faster processing.
public get supportsDeltaWithItems(): boolean {
return !!this.driver().supportsDeltaWithItems;
}
private async fetchRemoteDateOffset_() {
const tempFile = `${this.tempDirName()}/timeCheck${Math.round(Math.random() * 1000000)}.txt`;
const startTime = Date.now();
@@ -361,7 +362,7 @@ class FileApi {
return tryAndRepeat(() => this.driver_.clearRoot(this.baseDir()), this.requestRepeatCount());
}
public delta(path: string, options: any = null) {
public delta(path: string, options: any = null): Promise<PaginatedList> {
logger.debug(`delta ${this.fullPath(path)}`);
return tryAndRepeat(() => this.driver_.delta(this.fullPath(path), options), this.requestRepeatCount());
}