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 Jun 18, 2024
1 parent 69f226b commit f622658
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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"
}
15 changes: 11 additions & 4 deletions core/backend/src/IModelDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ class IModelSettings extends SettingsImpl {
throw new Error("Use IModelHost.appSettings to access settings of priority 'application' or lower");
}

public override * getSettingEntries<T extends Setting>(name: string): Iterable<{ value: T, dictionary: SettingsDictionary}> {
yield * super.getSettingEntries(name);
yield * IModelHost.appWorkspace.settings.getSettingEntries(name);
public override * getSettingEntries<T extends Setting>(name: string): Iterable<{ value: T, dictionary: SettingsDictionary }> {
yield* super.getSettingEntries(name);
yield* IModelHost.appWorkspace.settings.getSettingEntries(name);
}
}

Expand Down Expand Up @@ -2983,7 +2983,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 @@ -3017,6 +3017,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 f622658

Please sign in to comment.