-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Made Realm.compactRealmFile() more failure resilient. #955
Conversation
We should definitely start using core's |
I have added cores compact method and we now use that instead |
Realm realm = null; | ||
String path = realmFile.getAbsolutePath(); | ||
if (openRealms.get(path.hashCode()).get() > 0) { | ||
throw new IllegalStateException("Cannot compact a open Realm"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a -> an
Besides my comments: 👍 |
@@ -1717,32 +1716,28 @@ public static synchronized boolean deleteRealmFile(Context context, String fileN | |||
* | |||
* @param context an Android {@link android.content.Context} | |||
* @param fileName the name of the file to compact | |||
* @param key Key for opening a encrypted Realm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a -> an
} catch (IllegalStateException expected) { | ||
return; | ||
} | ||
fail(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you move fail()
inside the try
block, the return
isn't needed.
Will repeat this during the “how to talk about Realm” presentation. “Realm” is always capitalized i.e. “a Realm file” but in some context it’s easier to refer to the file extension, which is lowercase. For example:
|
Conflicts: changelog.txt
I have disabled compacting encrypted Realms as it fails on some devices. |
@@ -1,4 +1,5 @@ | |||
0.81 | |||
* Realm.compactRealmFile() now also works for encrypted Realms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, no :)
Made Realm.compactRealmFile() more failure resilient.
This look like a testcase error: when calling compact on the SharedGroup, it must be in the attached state (file must have been opened). In the testcases you close SharedGroup right before calling compact. I guess compact() should detect and assert. |
@finnschiermer The |
okidoki |
Awaits a new core release with fix for compact() on empty Realms.
Fixes compactRealmFile() doesn't cleanup properly #953
Realm.compactRealmFile()
now uses the methods provided by core which are more failure resilient.@emanuelez @kneth @bmunkholm