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 info = VmInfo();
List<String> lines = File(name + '/' + name + '.ports').readAsLinesSync();
for (var line in lines) {
List<String> parts = line.split(',');
switch (parts[0]) {
case 'ssh':
info.sshPort = parts[1];
break;
case 'spice':
info.spicePort = parts[1];
break;
File portsFile = File(name + '/' + name + '.ports');
if (portsFile.existsSync()) {
List<String> lines = portsFile.readAsLinesSync();
for (var line in lines) {
List<String> parts = line.split(',');
switch (parts[0]) {
case 'ssh':
info.sshPort = parts[1];
break;
case 'spice':
info.spicePort = parts[1];
break;
}
}
}
return info;