-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only allow one window to run export per user
Export will continue in a different window if one was closed Close #8063 Co-authored-by: wrd <[email protected]> Co-authored-by: ivk <[email protected]>
- Loading branch information
1 parent
4ccec4b
commit b0613a4
Showing
19 changed files
with
225 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@bundleInto:common-min | ||
|
||
import { TutanotaError } from "@tutao/tutanota-error" | ||
|
||
export const enum ExportErrorReason { | ||
LockedForUser = "LockedForUser", | ||
RunningForUser = "RunningForUser", | ||
} | ||
|
||
export class ExportError extends TutanotaError { | ||
// data field is respected by the WorkerProtocol. Other fields might not be passed | ||
constructor(msg: string, readonly data: ExportErrorReason) { | ||
super("ExportError", msg) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const enum LockResult { | ||
LockAcquired, | ||
AlreadyLocked, | ||
} | ||
|
||
/** A simple lock to prevent parallel mailbox export in multiple windows */ | ||
export class DesktopExportLock { | ||
private readonly locks: Set<Id> = new Set() | ||
|
||
acquireLock(userId: Id): LockResult { | ||
if (this.locks.has(userId)) { | ||
return LockResult.AlreadyLocked | ||
} else { | ||
this.locks.add(userId) | ||
return LockResult.LockAcquired | ||
} | ||
} | ||
|
||
unlock(userId: Id): void { | ||
this.locks.delete(userId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.