diff --git a/CHANGELOG.md b/CHANGELOG.md index e1909d65..98190ccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Acceptable mtime range (before verification fails) increased to 1000ms * Sync reliability improvements: * Added recoverable `EAI_AGAIN` error (closes [#159](https://github.com/steilerDev/icloud-photos-sync/issues/159)) + * Handling `RUNNING` indexing state (closes [#167](https://github.com/steilerDev/icloud-photos-sync/issues/167)) * Archive improvements: * Modified time is now properly preserved upon archiving (closes [#192](https://github.com/steilerDev/icloud-photos-sync/issues/192)) diff --git a/app/src/lib/icloud/icloud-photos/icloud-photos.ts b/app/src/lib/icloud/icloud-photos/icloud-photos.ts index 54521c49..5b762a6b 100644 --- a/app/src/lib/icloud/icloud-photos/icloud-photos.ts +++ b/app/src/lib/icloud/icloud-photos/icloud-photos.ts @@ -119,22 +119,25 @@ export class iCloudPhotos extends EventEmitter { return; } - if (state !== `FINISHED`) { + if (state === `RUNNING`) { const progress = result[0]?.fields?.progress?.value; + const indexingInProgressError = new iCPSError(ICLOUD_PHOTOS_ERR.INDEXING_IN_PROGRESS) if (progress) { - this.emit(ICLOUD_PHOTOS.EVENTS.ERROR, new iCPSError(ICLOUD_PHOTOS_ERR.INDEXING_IN_PROGRESS) - .addContext(`progress`, progress)); - return; + indexingInProgressError.addMessage(`progress ${progress}`) } + this.emit(ICLOUD_PHOTOS.EVENTS.ERROR, indexingInProgressError) + return + } - this.emit(ICLOUD_PHOTOS.EVENTS.ERROR, new iCPSError(ICLOUD_PHOTOS_ERR.INDEXING_STATE_UNKNOWN) - .addMessage(state) - .addContext(`icloudResult`, result)); - return; + if(state === `FINISHED`) { + this.logger.info(`Indexing finished, sync can start!`); + this.emit(ICLOUD_PHOTOS.EVENTS.READY); + return } - this.logger.info(`Indexing finished, sync can start!`); - this.emit(ICLOUD_PHOTOS.EVENTS.READY); + this.emit(ICLOUD_PHOTOS.EVENTS.ERROR, new iCPSError(ICLOUD_PHOTOS_ERR.INDEXING_STATE_UNKNOWN) + .addContext(`icloudResult`, result)); + return; } catch (err) { this.emit(ICLOUD_PHOTOS.EVENTS.ERROR, new iCPSError(ICLOUD_PHOTOS_ERR.INDEXING_STATE_UNKNOWN).addCause(err)); }