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