mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-03 22:37:35 +02:00
All: Optimise first synchronisation, when items have never been synced before
This commit is contained in:
parent
a38958ab7b
commit
15ce5cdd6e
@ -456,7 +456,7 @@ export default class Synchronizer {
|
|||||||
// (by setting an updated_time less than current time).
|
// (by setting an updated_time less than current time).
|
||||||
if (donePaths.indexOf(path) >= 0) throw new JoplinError(sprintf('Processing a path that has already been done: %s. sync_time was not updated? Remote item has an updated_time in the future?', path), 'processingPathTwice');
|
if (donePaths.indexOf(path) >= 0) throw new JoplinError(sprintf('Processing a path that has already been done: %s. sync_time was not updated? Remote item has an updated_time in the future?', path), 'processingPathTwice');
|
||||||
|
|
||||||
const remote: RemoteItem = await this.apiCall('stat', path);
|
const remote: RemoteItem = result.neverSyncedItemIds.includes(local.id) ? null : await this.apiCall('stat', path);
|
||||||
let action = null;
|
let action = null;
|
||||||
|
|
||||||
let reason = '';
|
let reason = '';
|
||||||
|
@ -18,6 +18,12 @@ export interface ItemsThatNeedDecryptionResult {
|
|||||||
items: any[];
|
items: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ItemsThatNeedSyncResult {
|
||||||
|
hasMore: boolean;
|
||||||
|
items: any[];
|
||||||
|
neverSyncedItemIds: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export default class BaseItem extends BaseModel {
|
export default class BaseItem extends BaseModel {
|
||||||
|
|
||||||
public static encryptionService_: any = null;
|
public static encryptionService_: any = null;
|
||||||
@ -583,7 +589,7 @@ export default class BaseItem extends BaseModel {
|
|||||||
throw new Error('Unreachable');
|
throw new Error('Unreachable');
|
||||||
}
|
}
|
||||||
|
|
||||||
static async itemsThatNeedSync(syncTarget: number, limit = 100) {
|
public static async itemsThatNeedSync(syncTarget: number, limit = 100): Promise<ItemsThatNeedSyncResult> {
|
||||||
const classNames = this.syncItemClassNames();
|
const classNames = this.syncItemClassNames();
|
||||||
|
|
||||||
for (let i = 0; i < classNames.length; i++) {
|
for (let i = 0; i < classNames.length; i++) {
|
||||||
@ -660,12 +666,13 @@ export default class BaseItem extends BaseModel {
|
|||||||
changedItems = await ItemClass.modelSelectAll(sql);
|
changedItems = await ItemClass.modelSelectAll(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const neverSyncedItemIds = neverSyncedItem.map((it: any) => it.id);
|
||||||
const items = neverSyncedItem.concat(changedItems);
|
const items = neverSyncedItem.concat(changedItems);
|
||||||
|
|
||||||
if (i >= classNames.length - 1) {
|
if (i >= classNames.length - 1) {
|
||||||
return { hasMore: items.length >= limit, items: items };
|
return { hasMore: items.length >= limit, items: items, neverSyncedItemIds };
|
||||||
} else {
|
} else {
|
||||||
if (items.length) return { hasMore: true, items: items };
|
if (items.length) return { hasMore: true, items: items, neverSyncedItemIds };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user