613
614
async flush(reason = WillSaveStateReason.NONE): Promise<void> {
616
>
// Signal event to collect changes
617
>
this._onWillSaveState.fire({ reason });
618
>
619
>
const applicationStorage = this.getStorage(StorageScope.APPLICATION);
620
>
const applicationSharedStorage = this.getStorage(StorageScope.APPLICATION_SHARED);
621
>
const profileStorage = this.getStorage(StorageScope.PROFILE);
622
>
const workspaceStorage = this.getStorage(StorageScope.WORKSPACE);
623
>
624
>
switch (reason) {
625
>
626
>
// Unspecific reason: just wait when data is flushed
627
>
case WillSaveStateReason.NONE:
628
>
await Promises.settled([
629
>
applicationStorage?.whenFlushed() ?? Promise.resolve(),
630
>
applicationSharedStorage?.whenFlushed() ?? Promise.resolve(),
631
>
profileStorage?.whenFlushed() ?? Promise.resolve(),
632
>
workspaceStorage?.whenFlushed() ?? Promise.resolve()
633
>
]);
634
>
break;
635
>
636
>
// Shutdown: we want to flush as soon as possible
637
>
// and not hit any delays that might be there
638
>
case WillSaveStateReason.SHUTDOWN:
639
await Promises.settled([
640
applicationStorage?.flush(0) ?? Promise.resolve(),