shouldCompactOnLaunch is passed the used bytes, not unused bytes

This commit is contained in:
Thomas Goyne 2018-06-18 10:03:17 -07:00 committed by Thomas Goyne
parent 2189feb640
commit 19f04253a7
3 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ X.Y.Z Release notes
`shouldCompactOnLaunch` config property for them.
### Bug fixes
* None.
* Fix incorrect documentation of the `shouldCompactOnLaunch` parameters.
### Internals
* None.

View File

@ -324,7 +324,7 @@ class Realm {
* a Realm for the first time during the life of a process to determine if it should be compacted
* before being returned to the user. The function takes two arguments:
* - `totalSize` - The total file size (data + free space)
* - `unusedSize` - The total bytes used by data in the file.
* - `usedSize` - The total bytes used by data in the file.
* It returns `true` to indicate that an attempt to compact the file should be made. The compaction
* will be skipped if another process is accessing it.
* @property {string} [path={@link Realm.defaultPath}] - The path to the file where the

View File

@ -518,10 +518,10 @@ void RealmClass<T>::constructor(ContextType ctx, ObjectType this_object, size_t
}
FunctionType should_compact_on_launch_function = Value::validated_to_function(ctx, compact_value, "shouldCompactOnLaunch");
config.should_compact_on_launch_function = [=](uint64_t total_bytes, uint64_t unused_bytes) {
config.should_compact_on_launch_function = [=](uint64_t total_bytes, uint64_t used_bytes) {
ValueType arguments[2] = {
Value::from_number(ctx, total_bytes),
Value::from_number(ctx, unused_bytes)
Value::from_number(ctx, used_bytes)
};
ValueType should_compact = Function<T>::callback(ctx, should_compact_on_launch_function, this_object, 2, arguments);