mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: manual restore
This commit is contained in:
@@ -90,6 +90,11 @@ class Backup {
|
||||
}
|
||||
|
||||
// Snippets
|
||||
if (force) {
|
||||
for (final s in snippets) {
|
||||
Stores.snippet.box.put(s.name, s);
|
||||
}
|
||||
} else {
|
||||
final nowSnippets = Stores.snippet.box.keys.toSet();
|
||||
final bakSnippets = snippets.map((e) => e.name).toSet();
|
||||
final newSnippets = bakSnippets.difference(nowSnippets);
|
||||
@@ -104,8 +109,14 @@ class Backup {
|
||||
for (final s in updateSnippets) {
|
||||
Stores.snippet.box.put(s, snippets.firstWhere((e) => e.name == s));
|
||||
}
|
||||
}
|
||||
|
||||
// ServerPrivateInfo
|
||||
if (force) {
|
||||
for (final s in spis) {
|
||||
Stores.server.box.put(s.id, s);
|
||||
}
|
||||
} else {
|
||||
final nowSpis = Stores.server.box.keys.toSet();
|
||||
final bakSpis = spis.map((e) => e.id).toSet();
|
||||
final newSpis = bakSpis.difference(nowSpis);
|
||||
@@ -120,8 +131,14 @@ class Backup {
|
||||
for (final s in updateSpis) {
|
||||
Stores.server.box.put(s, spis.firstWhere((e) => e.id == s));
|
||||
}
|
||||
}
|
||||
|
||||
// PrivateKeyInfo
|
||||
if (force) {
|
||||
for (final s in keys) {
|
||||
Stores.key.box.put(s.id, s);
|
||||
}
|
||||
} else {
|
||||
final nowKeys = Stores.key.box.keys.toSet();
|
||||
final bakKeys = keys.map((e) => e.id).toSet();
|
||||
final newKeys = bakKeys.difference(nowKeys);
|
||||
@@ -136,8 +153,12 @@ class Backup {
|
||||
for (final s in updateKeys) {
|
||||
Stores.key.box.put(s, keys.firstWhere((e) => e.id == s));
|
||||
}
|
||||
}
|
||||
|
||||
// History
|
||||
if (force) {
|
||||
Stores.history.box.putAll(history);
|
||||
} else {
|
||||
final nowHistory = Stores.history.box.keys.toSet();
|
||||
final bakHistory = history.keys.toSet();
|
||||
final newHistory = bakHistory.difference(nowHistory);
|
||||
@@ -152,8 +173,12 @@ class Backup {
|
||||
for (final s in updateHistory) {
|
||||
Stores.history.box.put(s, history[s]);
|
||||
}
|
||||
}
|
||||
|
||||
// Container
|
||||
if (force) {
|
||||
Stores.container.box.putAll(container);
|
||||
} else {
|
||||
final nowContainer = Stores.container.box.keys.toSet();
|
||||
final bakContainer = container.keys.toSet();
|
||||
final newContainer = bakContainer.difference(nowContainer);
|
||||
@@ -168,6 +193,7 @@ class Backup {
|
||||
for (final s in updateContainer) {
|
||||
Stores.container.box.put(s, container[s]);
|
||||
}
|
||||
}
|
||||
|
||||
Pros.reload();
|
||||
RNodes.app.notify();
|
||||
|
||||
Reference in New Issue
Block a user