fix: docker parse (#414)

Fixes #395
This commit is contained in:
lollipopkit🏳️‍⚧️
2024-06-23 18:37:05 +08:00
committed by GitHub
parent 2e9ad7d7cb
commit d6e37b058f
2 changed files with 34 additions and 11 deletions

View File

@@ -160,11 +160,18 @@ class ContainerProvider extends ChangeNotifier {
}
// Parse images
final imageRaw = ContainerCmdType.images.find(segments);
final imageRaw = ContainerCmdType.images.find(segments).trim();
final isEntireJson = imageRaw.startsWith('[') && imageRaw.endsWith(']');
try {
final imgLines = imageRaw.split('\n');
imgLines.removeWhere((element) => element.isEmpty);
images = imgLines.map((e) => ContainerImg.fromRawJson(e, type)).toList();
if (isEntireJson) {
images = (json.decode(imageRaw) as List)
.map((e) => ContainerImg.fromRawJson(json.encode(e), type))
.toList();
} else {
final lines = imageRaw.split('\n');
lines.removeWhere((element) => element.isEmpty);
images = lines.map((e) => ContainerImg.fromRawJson(e, type)).toList();
}
} catch (e, trace) {
error = ContainerErr(
type: ContainerErrType.parseImages,
@@ -298,6 +305,6 @@ enum ContainerCmdType {
}) {
return ContainerCmdType.values
.map((e) => e.exec(type, sudo: sudo, includeStats: includeStats))
.join(' && echo ${ShellFunc.seperator} && ');
.join('\necho ${ShellFunc.seperator}\n');
}
}