fix: docker cmd wrap

This commit is contained in:
lollipopkit
2023-11-20 16:57:31 +08:00
parent f093853d21
commit b696cdff08
6 changed files with 33 additions and 34 deletions

View File

@@ -239,7 +239,7 @@ enum DockerCmdType {
}
}
static final execAll = values.map((e) => e.exec).join(_cmdDivider);
static final execAll = values.map((e) => e.exec).join(' && echo $seperator && ');
}
enum BSDStatusCmdType {

View File

@@ -64,7 +64,7 @@ class DockerProvider extends ChangeNotifier {
final segments = raw.split(seperator);
if (segments.length != DockerCmdType.values.length) {
error = DockerErr(type: DockerErrType.segmentsNotMatch);
Loggers.parse.warning('Docker segments: ${segments.length}');
Loggers.parse.warning('Docker segments: ${segments.length}\n$raw');
notifyListeners();
return;
}
@@ -171,16 +171,14 @@ class DockerProvider extends ChangeNotifier {
return null;
}
// wrap cmd with `docker host & sudo`
/// wrap cmd with `docker host`
String _wrap(String cmd) {
final dockerHost = Stores.docker.fetch(hostId!);
if (dockerHost == null || dockerHost.isEmpty) {
if (userName != 'root') {
return 'sudo $cmd';
}
} else {
final dockerHost = Stores.docker.fetch(hostId);
cmd = 'export LANG=en_US.UTF-8 && $cmd';
final noDockerHost = dockerHost?.isEmpty ?? true;
if (!noDockerHost) {
cmd = 'export DOCKER_HOST=$dockerHost && $cmd';
}
return 'export LANG=en_US.UTF-8 && $cmd';
return cmd;
}
}

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 644;
static const int build = 645;
static const String engine = "3.16.0";
static const String buildAt = "2023-11-20 11:49:47";
static const int modifications = 4;
static const int script = 26;
static const String buildAt = "2023-11-20 16:47:25";
static const int modifications = 5;
static const int script = 27;
}

View File

@@ -3,7 +3,7 @@ import '../../core/persistant_store.dart';
class DockerStore extends PersistentStore<String> {
DockerStore() : super('docker');
String? fetch(String id) {
String? fetch(String? id) {
return box.get(id);
}