Added check for ports file when launching a new VM re #28 (#29)

This commit is contained in:
Ben Hall 2021-11-15 21:56:49 +00:00 committed by GitHub
parent 5afb732f5e
commit 4c17797603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 10 deletions

View File

@ -76,16 +76,19 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
VmInfo _parseVmInfo(name) { VmInfo _parseVmInfo(name) {
VmInfo info = VmInfo(); VmInfo info = VmInfo();
List<String> lines = File(name + '/' + name + '.ports').readAsLinesSync(); File portsFile = File(name + '/' + name + '.ports');
for (var line in lines) { if (portsFile.existsSync()) {
List<String> parts = line.split(','); List<String> lines = portsFile.readAsLinesSync();
switch (parts[0]) { for (var line in lines) {
case 'ssh': List<String> parts = line.split(',');
info.sshPort = parts[1]; switch (parts[0]) {
break; case 'ssh':
case 'spice': info.sshPort = parts[1];
info.spicePort = parts[1]; break;
break; case 'spice':
info.spicePort = parts[1];
break;
}
} }
} }
return info; return info;