From 19f04253a70da832a719834909fd0213a9eb806d Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 18 Jun 2018 10:03:17 -0700 Subject: [PATCH] shouldCompactOnLaunch is passed the used bytes, not unused bytes --- CHANGELOG.md | 2 +- docs/realm.js | 2 +- src/js_realm.hpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9c3579b..2a0896c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/docs/realm.js b/docs/realm.js index e6eb215d..0f376ffa 100644 --- a/docs/realm.js +++ b/docs/realm.js @@ -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 diff --git a/src/js_realm.hpp b/src/js_realm.hpp index fea2206f..2a11d51d 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -518,10 +518,10 @@ void RealmClass::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::callback(ctx, should_compact_on_launch_function, this_object, 2, arguments);