Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling sync/compact combo #3899

Merged
merged 3 commits into from
Dec 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 2.2.2

### Object Server API Changes (In Beta)

* Disabled `Realm.compactRealm()` when sync is enabled as it might corrupt the Realm (https://github.com/realm/realm-core/issues/2345).

### Enhancements

* All major public classes are now non-final. This is mostly a compromise to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,14 @@ public void toString_nonEmpty() {
String configStr = config.toString();
assertTrue(configStr != null && !configStr.isEmpty());
}

// FIXME: This test can be removed when https://github.com/realm/realm-core/issues/2345 is resolved
@Test(expected = UnsupportedOperationException.class)
public void compact_NotAllowed() {
SyncUser user = createTestUser();
String url = "realm://objectserver.realm.io/default";
SyncConfiguration config = new SyncConfiguration.Builder(user, url).build();

Realm.compactRealm(config);
}
}
7 changes: 5 additions & 2 deletions realm/realm-library/src/main/java/io/realm/Realm.java
Original file line number Diff line number Diff line change
Expand Up @@ -1555,10 +1555,13 @@ public static boolean deleteRealm(RealmConfiguration configuration) {
*
* @param configuration a {@link RealmConfiguration} pointing to a Realm file.
* @return {@code true} if successful, {@code false} if any file operation failed.
* @throws IllegalArgumentException if the realm file is encrypted. Compacting an encrypted Realm file is not
* supported yet.
* @throws UnsupportedOperationException if Realm is synchronized.
*/
public static boolean compactRealm(RealmConfiguration configuration) {
// FIXME: remove this restriction when https://github.com/realm/realm-core/issues/2345 is resolved
if (configuration.isSyncConfiguration()) {
throw new UnsupportedOperationException("Compacting is not supported yet on synced Realms. See https://github.com/realm/realm-core/issues/2345");
}
return BaseRealm.compactRealm(configuration);
}

Expand Down