Add compact strategy to save on disk space
This commit is contained in:
parent
4fb06c8462
commit
a33ebe3ffd
1 changed files with 12 additions and 2 deletions
|
@ -27,6 +27,8 @@ class Settings {
|
|||
if (!isValid()) return;
|
||||
var box = Hive.box("settings");
|
||||
box.put("entry", inst);
|
||||
|
||||
box.compact();
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
|
@ -39,12 +41,20 @@ class Settings {
|
|||
|
||||
Future<Box<E>> Open<E>() {
|
||||
Close();
|
||||
return Hive.openBox("settings", path: game_path);
|
||||
return Hive.openBox(
|
||||
"settings",
|
||||
path: game_path,
|
||||
compactionStrategy: (entries, deletedEntries) {
|
||||
return deletedEntries > 1;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static void Close() {
|
||||
if (Hive.isBoxOpen("settings")) {
|
||||
Hive.box("settings").close();
|
||||
var box = Hive.box("settings");
|
||||
box.compact();
|
||||
box.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue