You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	All: Optimise first synchronisation, when items have never been synced before
This commit is contained in:
		| @@ -456,7 +456,7 @@ export default class Synchronizer { | ||||
| 						//   (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'); | ||||
|  | ||||
| 						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 reason = ''; | ||||
|   | ||||
| @@ -18,6 +18,12 @@ export interface ItemsThatNeedDecryptionResult { | ||||
| 	items: any[]; | ||||
| } | ||||
|  | ||||
| export interface ItemsThatNeedSyncResult { | ||||
| 	hasMore: boolean; | ||||
| 	items: any[]; | ||||
| 	neverSyncedItemIds: string[]; | ||||
| } | ||||
|  | ||||
| export default class BaseItem extends BaseModel { | ||||
|  | ||||
| 	public static encryptionService_: any = null; | ||||
| @@ -583,7 +589,7 @@ export default class BaseItem extends BaseModel { | ||||
| 		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(); | ||||
|  | ||||
| 		for (let i = 0; i < classNames.length; i++) { | ||||
| @@ -660,12 +666,13 @@ export default class BaseItem extends BaseModel { | ||||
| 				changedItems = await ItemClass.modelSelectAll(sql); | ||||
| 			} | ||||
|  | ||||
| 			const neverSyncedItemIds = neverSyncedItem.map((it: any) => it.id); | ||||
| 			const items = neverSyncedItem.concat(changedItems); | ||||
|  | ||||
| 			if (i >= classNames.length - 1) { | ||||
| 				return { hasMore: items.length >= limit, items: items }; | ||||
| 				return { hasMore: items.length >= limit, items: items, neverSyncedItemIds }; | ||||
| 			} else { | ||||
| 				if (items.length) return { hasMore: true, items: items }; | ||||
| 				if (items.length) return { hasMore: true, items: items, neverSyncedItemIds }; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user