temp file 중복실행 방지

This commit is contained in:
leedongmyung[desktop] 2023-10-29 12:13:30 +09:00
parent 811ffa9f6a
commit 2b6510f0a5

View file

@ -115,11 +115,9 @@ class ProcessExecutor {
try {
var processData = ProcessData();
var fileName = DateTime.now();
if (Platform.isMacOS || Platform.isLinux) {
workspace = workspace ?? Directory.current.path;
var file =
File('$workspace/temp_${fileName.microsecondsSinceEpoch}.sh');
var file = File('$workspace/$tempFileName');
processData.file = file;
print('Execute Shell: ${file.path} \n ${shell.toString()}');
if (await file.exists()) {
@ -135,8 +133,7 @@ class ProcessExecutor {
}
} else if (Platform.isWindows) {
workspace = workspace ?? Directory.current.path;
var file =
File('$workspace/temp_${fileName.microsecondsSinceEpoch}.bat');
var file = File('$workspace/$tempFileName');
processData.file = file;
print('Execute Shell: ${file.path} \n ${shell.toString()}');
if (await file.exists()) {
@ -167,7 +164,7 @@ class ProcessExecutor {
ProcessResult? processResult;
if (Platform.isMacOS || Platform.isLinux) {
workspace = workspace ?? Directory.current.path;
var file = File('$workspace/temp.sh');
var file = File('$workspace/$tempFileName');
print('Execute Shell: ${file.path} \n ${shell.toString()}');
file.createSync();
file.writeAsStringSync(shell.toString());
@ -190,7 +187,7 @@ class ProcessExecutor {
c.complete(processResult);
} else if (Platform.isWindows) {
workspace = workspace ?? Directory.current.path;
var file = File('$workspace/temp.bat');
var file = File('$workspace/$tempFileName');
print('Execute Bat: ${file.path} \n ${shell.toString()}');
file.createSync();
file.writeAsStringSync(shell.toString());
@ -213,6 +210,13 @@ class ProcessExecutor {
return c.future;
}
static String get tempFileName {
if (Platform.isMacOS || Platform.isLinux)
return 'temp_${DateTime.now().microsecondsSinceEpoch}.sh';
else
return 'temp_${DateTime.now().microsecondsSinceEpoch}.bat';
}
static bool getSuccess(int exitCode) {
if (Platform.isMacOS || Platform.isLinux) return exitCode == 0;
if (Platform.isWindows) return exitCode == 1;