Skip to content

Commit

Permalink
Return bool from ClientResetError.resetRealm to indicate if reset was…
Browse files Browse the repository at this point in the history
… initiated or not
  • Loading branch information
nielsenko committed Jan 9, 2023
1 parent 36a5c2d commit c1af54c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,16 @@ class ClientResetError extends SyncError {
/// Initiates the client reset process.
///
/// Returns> `true` if actions were run successfully, `false` otherwise.
///
/// All Realm instances for that path must be closed before this method is called or an
/// [RealmException] will be thrown.
void resetRealm() {
bool resetRealm() {
if (_config is! FlexibleSyncConfiguration) {
throw RealmException("The current configuration is not FlexibleSyncConfiguration.");
}
final flexibleConfig = _config as FlexibleSyncConfiguration;
realmCore.immediatelyRunFileActions(flexibleConfig.user.app, flexibleConfig.path);
return realmCore.immediatelyRunFileActions(flexibleConfig.user.app, flexibleConfig.path);
}
}
Expand Down
8 changes: 5 additions & 3 deletions lib/src/native/realm_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2303,10 +2303,12 @@ class _RealmCore {
});
}

void immediatelyRunFileActions(App app, String realmPath) {
using((arena) {
_realmLib.invokeGetBool(() => _realmLib.realm_sync_immediately_run_file_actions(app.handle._pointer, realmPath.toCharPtr(arena)),
bool immediatelyRunFileActions(App app, String realmPath) {
return using((arena) {
final out_did_run = arena<Bool>();
_realmLib.invokeGetBool(() => _realmLib.realm_sync_immediately_run_file_actions(app.handle._pointer, realmPath.toCharPtr(arena), out_did_run),
"An error occurred while resetting the Realm. Check if the file is in use: '$realmPath'");
return out_did_run.value;
});
}
}
Expand Down

0 comments on commit c1af54c

Please sign in to comment.