-
-
Notifications
You must be signed in to change notification settings - Fork 208
Refactor: Modify detection process for Inno Setup 6 #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,20 +6,30 @@ import 'package:shell_executor/shell_executor.dart'; | |
|
|
||
| class InnoSetupCompiler { | ||
| Future<bool> compile(InnoSetupScript script) async { | ||
| File file = await script.createFile(); | ||
|
|
||
| ProcessResult processResult; | ||
|
|
||
| // First, try the default installation path | ||
| Directory innoSetupDirectory = | ||
| Directory('C:\\Program Files (x86)\\Inno Setup 6'); | ||
|
|
||
| if (!innoSetupDirectory.existsSync()) { | ||
| throw Exception('`Inno Setup 6` was not installed.'); | ||
| if (innoSetupDirectory.existsSync()) { | ||
| // Use ISCC from the default installation directory | ||
| processResult = await $( | ||
| p.join(innoSetupDirectory.path, 'ISCC.exe'), | ||
| [file.path], | ||
| ); | ||
| } else { | ||
| // Fall back to PATH | ||
| try { | ||
| processResult = await $('ISCC', [file.path]); | ||
| } on ProcessException { | ||
| throw Exception( | ||
| '\'Inno Setup 6\' was not installed or ISCC is not in PATH.'); | ||
| } | ||
| } | ||
|
Comment on lines
17
to
31
|
||
|
|
||
| File file = await script.createFile(); | ||
|
|
||
| ProcessResult processResult = await $( | ||
| p.join(innoSetupDirectory.path, 'ISCC.exe'), | ||
| [file.path], | ||
| ); | ||
|
|
||
| if (processResult.exitCode != 0) { | ||
| return false; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The temporary file is not cleaned up when an exception is thrown. If the compiler is not found in PATH (line 28-30), the exception is thrown before file.deleteSync() is called (line 37). This will leave temporary script files on disk. Consider using a try-finally block to ensure cleanup, or moving file deletion earlier to handle all error paths.