Skip to content

Commit

Permalink
fix: privatekey update actually creates a new key (#541)
Browse files Browse the repository at this point in the history
Fixes #540
  • Loading branch information
lollipopkit authored Aug 16, 2024
1 parent 7558b48 commit ef29767
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 34 deletions.
1 change: 0 additions & 1 deletion lib/data/model/app/backup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:logging/logging.dart';
import 'package:server_box/data/model/server/private_key_info.dart';
import 'package:server_box/data/model/server/server_private_info.dart';
import 'package:server_box/data/model/server/snippet.dart';
import 'package:server_box/data/provider/base.dart';
import 'package:server_box/data/res/misc.dart';
import 'package:server_box/data/res/rebuild.dart';
import 'package:server_box/data/res/store.dart';
Expand Down
20 changes: 0 additions & 20 deletions lib/data/provider/base.dart

This file was deleted.

5 changes: 3 additions & 2 deletions lib/data/provider/private_key.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:fl_lib/fl_lib.dart';
import 'package:server_box/data/model/server/private_key_info.dart';
import 'package:server_box/data/provider/base.dart';
import 'package:server_box/data/res/store.dart';

class PrivateKeyProvider extends Provider {
Expand Down Expand Up @@ -31,10 +30,12 @@ class PrivateKeyProvider extends Provider {
final idx = pkis.value.indexWhere((e) => e.id == old.id);
if (idx == -1) {
pkis.value.add(newInfo);
Stores.key.put(newInfo);
Stores.key.delete(old);
} else {
pkis.value[idx] = newInfo;
Stores.key.put(newInfo);
}
pkis.notify();
Stores.key.put(newInfo);
}
}
3 changes: 0 additions & 3 deletions lib/data/provider/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import 'package:server_box/core/utils/ssh_auth.dart';
import 'package:server_box/data/model/app/error.dart';
import 'package:server_box/data/model/app/shell_func.dart';
import 'package:server_box/data/model/server/system.dart';
import 'package:server_box/data/provider/base.dart';
// import 'package:server_box/data/model/sftp/req.dart';
// import 'package:server_box/data/res/provider.dart';
import 'package:server_box/data/res/store.dart';

import 'package:server_box/core/utils/server.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/data/provider/sftp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';

import 'package:fl_lib/fl_lib.dart';
import 'package:server_box/data/model/sftp/worker.dart';
import 'package:server_box/data/provider/base.dart';

class SftpProvider extends Provider {
const SftpProvider._();
Expand Down
1 change: 0 additions & 1 deletion lib/data/provider/snippet.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:fl_lib/fl_lib.dart';
import 'package:server_box/data/model/server/snippet.dart';
import 'package:server_box/data/provider/base.dart';
import 'package:server_box/data/res/store.dart';

class SnippetProvider extends Provider {
Expand Down
5 changes: 3 additions & 2 deletions lib/view/page/private_key/edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
try {
final decrypted = await Computer.shared.start(decyptPem, [key, pwd]);
final pki = PrivateKeyInfo(id: name, key: decrypted);
if (widget.pki != null) {
PrivateKeyProvider.update(widget.pki!, pki);
final originPki = widget.pki;
if (originPki != null) {
PrivateKeyProvider.update(originPki, pki);
} else {
PrivateKeyProvider.add(pki);
}
Expand Down
8 changes: 5 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,11 @@ packages:
fl_lib:
dependency: "direct main"
description:
path: "../fl_lib"
relative: true
source: path
path: "."
ref: "v1.0.141"
resolved-ref: "2fb1532cd2fd08dd807e9776b2b50b5d8ee94388"
url: "https://github.com/lppcg/fl_lib"
source: git
version: "0.0.1"
flutter:
dependency: "direct main"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies:
fl_lib:
git:
url: https://github.com/lppcg/fl_lib
ref: v1.0.140
ref: v1.0.141

dependency_overrides:
# dartssh2:
Expand Down

0 comments on commit ef29767

Please sign in to comment.