Skip to content

Commit

Permalink
Refresh changeset property when reopening briefcase (#6861)
Browse files Browse the repository at this point in the history
  • Loading branch information
swwilson-bsi authored and aruniverse committed Jun 19, 2024
1 parent 2880160 commit 33248f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-backend",
"comment": "BriefcaseDb.closeAndReopen now refreshes the changeset property in case another process pulled changes",
"type": "none"
}
],
"packageName": "@itwin/core-backend"
}
9 changes: 8 additions & 1 deletion core/backend/src/IModelDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2946,7 +2946,7 @@ export class BriefcaseDb extends IModelDb {
* Execute the supplied function.
* If the briefcase was read-only, reopen the native briefcase as read-only.
* @note this._openMode is not changed from its initial value.
* @internal Exported strictly for tests.
* @internal Exported strictly for tests
*/
public async executeWritable(func: () => Promise<void>): Promise<void> {
const fileName = this.pathName;
Expand Down Expand Up @@ -2980,6 +2980,13 @@ export class BriefcaseDb extends IModelDb {

// Restore the native db's pointer to this JavaScript object.
this.nativeDb.setIModelDb(this);

// refresh cached properties that could have been changed by another process writing to the same briefcase
this.changeset = this.nativeDb.getCurrentChangeset();

// assert what should never change
if (this.iModelId !== this.nativeDb.getIModelId() || this.iTwinId !== this.nativeDb.getITwinId())
throw new Error("closeAndReopen detected change in iModelId and/or iTwinId");
}

/** Pull and apply changesets from iModelHub */
Expand Down

0 comments on commit 33248f4

Please sign in to comment.