Attempt to fix hung process on windows

This commit is contained in:
zontreck 2024-11-25 17:03:54 -07:00
parent b10c2a5527
commit 6507d6678e
4 changed files with 14 additions and 9 deletions

View file

@ -1,3 +1,3 @@
class Consts { class Consts {
static const VERSION = "1.1.112524.1211"; static const VERSION = "1.1.112524.1703";
} }

View file

@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:servermanager/structs/discordHookHelper.dart';
import '../structs/mod.dart'; import '../structs/mod.dart';
import '../structs/settings.dart'; import '../structs/settings.dart';

View file

@ -13,6 +13,11 @@ Future<bool> requiresWine() async {
Future<void> runWine(String command, List<String> argx) async { Future<void> runWine(String command, List<String> argx) async {
bool requiredWine = await requiresWine(); bool requiredWine = await requiresWine();
if (Platform.isWindows) {
await runDetachedWine(command, argx, Directory.current.path);
return;
}
Settings settings = Settings(); Settings settings = Settings();
Directory dir = Directory(settings.getWinePrefixPath()); Directory dir = Directory(settings.getWinePrefixPath());
@ -29,14 +34,15 @@ Future<void> runWine(String command, List<String> argx) async {
args.addAll(argx); args.addAll(argx);
ProcessResult? res; ProcessResult? res;
if (requiredWine) if (requiredWine) {
res = await Process.run( res = await Process.run(
"wine", "wine",
args, // Run arbitrary command with arguments args, // Run arbitrary command with arguments
environment: env, environment: env,
); );
else } else {
res = await Process.run("cmd", ["/C"] + args, environment: {}); res = await Process.run("cmd", ["/C"] + args, environment: {});
}
print('Exit code: ${res.exitCode}'); print('Exit code: ${res.exitCode}');
print('stdout: ${res.stdout}'); print('stdout: ${res.stdout}');
@ -97,18 +103,18 @@ Future<void> runDetachedWine(
List<String> args = [command]; List<String> args = [command];
args.addAll(argx); args.addAll(argx);
if (requiredWine) if (requiredWine) {
StateMachine.PROC = await Process.start( StateMachine.PROC = await Process.start(
"wine", args, // Run arbitrary command with arguments "wine", args, // Run arbitrary command with arguments
environment: env, environment: env,
workingDirectory: workingDir, workingDirectory: workingDir,
mode: ProcessStartMode.detachedWithStdio); mode: ProcessStartMode.detachedWithStdio);
else } else {
StateMachine.PROC = await Process.start( StateMachine.PROC = await Process.start("cmd", ["/C"] + args,
args[0], args.length > 1 ? args.sublist(1) : [],
environment: {}, environment: {},
workingDirectory: workingDir, workingDirectory: workingDir,
mode: ProcessStartMode.detachedWithStdio); mode: ProcessStartMode.detachedWithStdio);
}
try { try {
StateMachine.PROC!.stdout.forEach((line) {}); StateMachine.PROC!.stdout.forEach((line) {});

View file

@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.1.112524+1211 version: 1.1.112524+1703
environment: environment:
sdk: ">=3.1.4 <4.0.0" sdk: ">=3.1.4 <4.0.0"