Skip to content

Commit

Permalink
Handling running indexing state
Browse files Browse the repository at this point in the history
  • Loading branch information
steilerDev committed Feb 17, 2023
1 parent d06a963 commit 4c17d63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
23 changes: 13 additions & 10 deletions app/src/lib/icloud/icloud-photos/icloud-photos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 4c17d63

Please sign in to comment.