Skip to content

Commit 9646971

Browse files
committed
Fixed thread issue with new warning
Possible the cause of crashes
1 parent a765b5c commit 9646971

18 files changed

+59
-38
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
##
44
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
55

6+
Advanced Installer/
7+
68
# User-specific files
79
*.suo
810
*.user
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Advanced Installer/Advanced Installer.aip

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
<ROW BootstrOptKey="GlobalOptions" DownloadFolder="[AppDataFolder][|Manufacturer]\[|ProductName]\prerequisites" Options="2"/>
159159
</COMPONENT>
160160
<COMPONENT cid="caphyon.advinst.msicomp.BuildComponent">
161-
<ROW BuildKey="DefaultBuild" BuildName="DefaultBuild" BuildOrder="1" BuildType="0" PackageFileName="ACCsetup" Languages="en" InstallationType="4" CabsLocation="1" PackageType="1" FilesInsideExe="true" ExeIconPath="..\..\..\..\..\Desktop\logo_ico - Copy.ico" UseLargeSchema="true" ExeName="ACCsetup" UACExecutionLevel="2"/>
161+
<ROW BuildKey="DefaultBuild" BuildName="DefaultBuild" BuildOrder="1" BuildType="0" PackageFileName="ACCsetup" Languages="en" InstallationType="4" CabsLocation="1" PackageType="1" FilesInsideExe="true" ExeIconPath="..\..\ACC stuff\Images\Icons\logo_ico.ico" UseLargeSchema="true" ExeName="ACCsetup" UACExecutionLevel="2"/>
162162
</COMPONENT>
163163
<COMPONENT cid="caphyon.advinst.msicomp.DictionaryComponent">
164164
<ROW Path="&lt;AI_DICTS&gt;ui.ail"/>
@@ -273,7 +273,7 @@
273273
<ROW Feature_="MainFeature" Component_="bootstrap.min.old.css"/>
274274
</COMPONENT>
275275
<COMPONENT cid="caphyon.advinst.msicomp.MsiIconsComponent">
276-
<ROW Name="logo_ico.exe" SourcePath="..\..\..\..\..\Desktop\logo_ico.ico" Index="0"/>
276+
<ROW Name="logo_ico.exe" SourcePath="..\..\ACC stuff\Images\Icons\logo_ico.ico" Index="0"/>
277277
</COMPONENT>
278278
<COMPONENT cid="caphyon.advinst.msicomp.MsiInstExSeqComponent">
279279
<ROW Action="AI_DOWNGRADE" Condition="AI_NEWERPRODUCTFOUND AND (UILevel &lt;&gt; 5)" Sequence="210"/>

AssistantComputerControl/AssistantComputerControl.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProjectGuid>{404B42F4-E135-4D2F-8FD0-20A590814930}</ProjectGuid>
8-
<OutputType>Exe</OutputType>
8+
<OutputType>WinExe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>AssistantComputerControl</RootNamespace>
1111
<AssemblyName>AssistantComputerControl</AssemblyName>

AssistantComputerControl/CleanupService.cs

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* AssistantComputerControl
33
* Made by Albert MN.
4-
* Updated: v1.4.0, 15-01-2020
4+
* Updated: v1.4.4, 08-05-2021
55
*
66
* Use:
77
* - Cleans action files up after they've been processed
@@ -69,7 +69,7 @@ void ExtraCleanup() {
6969

7070
Process p = new Process();
7171
p.StartInfo.FileName = "powershell.exe";
72-
p.StartInfo.Arguments = $"-WindowStyle Hidden -file \"{ps1File}\" \"{Path.Combine(MainProgram.CheckPath(), "*")}\" \"*.{Properties.Settings.Default.ActionFileExtension}\"";
72+
p.StartInfo.Arguments = $"-WindowStyle Hidden -file \"{ps1File}\" \"{Path.Combine(MainProgram.CheckPath(true), "*")}\" \"*.{Properties.Settings.Default.ActionFileExtension}\"";
7373
p.StartInfo.UseShellExecute = false;
7474
p.StartInfo.CreateNoWindow = true;
7575
p.Start();
@@ -89,29 +89,36 @@ void ExtraCleanup() {
8989
}
9090

9191
private bool EmptyCheck() {
92-
return Directory.GetFiles(MainProgram.CheckPath()).Length > 0;
92+
return Directory.GetFiles(MainProgram.CheckPath(true)).Length > 0;
9393
}
9494

9595
private int AllHiddenCheck() {
9696
int count = 0;
97-
foreach (string file in Directory.GetFiles(MainProgram.CheckPath(), "*." + Properties.Settings.Default.ActionFileExtension)) {
98-
bool hidden = (File.GetAttributes(file) & FileAttributes.Hidden) == FileAttributes.Hidden;
99-
if (!hidden || file.Contains("computerAction")) {
100-
//MainProgram.DoDebug("[CLEANUP] Found file; " + file);
101-
count++;
97+
foreach (string file in Directory.GetFiles(MainProgram.CheckPath(true), "*." + Properties.Settings.Default.ActionFileExtension)) {
98+
if (File.Exists(file)) {
99+
try {
100+
//Shouldn't think it'd be needed, but it is
101+
bool hidden = (File.GetAttributes(file) & FileAttributes.Hidden) == FileAttributes.Hidden;
102+
if (!hidden || file.Contains("computerAction")) {
103+
//MainProgram.DoDebug("[CLEANUP] Found file; " + file);
104+
count++;
105+
}
106+
} catch {
107+
//Probably failed to get attribute
108+
}
102109
}
103110
}
104111
return count;
105112
}
106113

107114
private bool Check() {
108115
if (EmptyCheck()) {
109-
DirectoryInfo di = new DirectoryInfo(MainProgram.CheckPath());
116+
DirectoryInfo di = new DirectoryInfo(MainProgram.CheckPath(true));
110117

111118
int numFiles = 0;
112119

113120
try {
114-
foreach (string file in Directory.GetFiles(MainProgram.CheckPath(), "*." + Properties.Settings.Default.ActionFileExtension)) {
121+
foreach (string file in Directory.GetFiles(MainProgram.CheckPath(true), "*." + Properties.Settings.Default.ActionFileExtension)) {
115122
//if (cleanedFiles.Contains(file)) continue;
116123

117124
bool hidden = (File.GetAttributes(file) & FileAttributes.Hidden) == FileAttributes.Hidden;
@@ -126,7 +133,7 @@ private bool Check() {
126133

127134
//string newFilename = Path.Combine(Path.GetDirectoryName(file), "action_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + "_" + Guid.NewGuid() + "." + Properties.Settings.Default.ActionFileExtension);
128135
//string newFilename = Path.Combine(tmpFolder, "action_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + "_" + Guid.NewGuid() + "." + Properties.Settings.Default.ActionFileExtension);
129-
//string newFilename = Path.Combine(Path.Combine(MainProgram.CheckPath(), "used_actions"), "action_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + "_" + Guid.NewGuid() + "." + Properties.Settings.Default.ActionFileExtension);
136+
//string newFilename = Path.Combine(Path.Combine(MainProgram.CheckPath(true), "used_actions"), "action_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + "_" + Guid.NewGuid() + "." + Properties.Settings.Default.ActionFileExtension);
130137
//File.Move(file, newFilename);
131138
//File.Delete(newFilename);
132139
File.Delete(file);

AssistantComputerControl/MainProgram.cs

+22-20
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
namespace AssistantComputerControl {
2828
class MainProgram {
29-
public const string softwareVersion = "1.4.3",
30-
releaseDate = "2021-04-21 00:33:00", //YYYY-MM-DD H:i:s - otherwise it gives an error
29+
public const string softwareVersion = "1.4.4",
30+
releaseDate = "2021-04-27 00:05:00", //YYYY-MM-DD H:i:s - otherwise it gives an error
3131
appName = "AssistantComputerControl",
3232

3333
sentryToken = "super_secret";
@@ -436,8 +436,8 @@ public static void TaskSchedulerSetup () {
436436
//Register the task in the root folder
437437
ts.RootFolder.RegisterTaskDefinition(@"AssistantComputerControl cleanup", td);
438438
}
439-
} catch {
440-
DoDebug("Failed to create / update Task Scheduler service");
439+
} catch (Exception e) {
440+
DoDebug("Failed to create / update Task Scheduler service; " + e.Message);
441441
}
442442
}
443443

@@ -658,8 +658,8 @@ public static void SetStartup(bool status, bool setThroughSoftware = false) {
658658
//Register the task in the root folder
659659
ts.RootFolder.RegisterTaskDefinition(@"AssistantComputerControl startup", td);
660660
}
661-
} catch {
662-
DoDebug("Failed to create / update Task Scheduler startup service");
661+
} catch (Exception e) {
662+
DoDebug("Failed to create / update Task Scheduler startup service; " + e.Message);
663663
}
664664
} else {
665665
//Create "Task Scheduler" service; run ACC on startup & log on, added by Shelby Marvell
@@ -668,8 +668,8 @@ public static void SetStartup(bool status, bool setThroughSoftware = false) {
668668
// Register the task in the root folder
669669
ts.RootFolder.DeleteTask(@"AssistantComputerControl startup");
670670
}
671-
} catch {
672-
DoDebug("Failed to create / update Task Scheduler startup service");
671+
} catch (Exception e) {
672+
DoDebug("Failed to create / update Task Scheduler startup service; " + e.Message);
673673
}
674674
}
675675

@@ -758,20 +758,24 @@ public static void DefaultPathIssue() {
758758
DialogResult dialogResult = MessageBox.Show("It seems the path to the cloud service wasn't set correctly. Choose \"Yes\" to go through the setup again. If this doesn't work, try restarting the ACC software.", "Whoops, problem!", MessageBoxButtons.YesNo);
759759
DoDebug(dialogResult.ToString());
760760

761-
if (dialogResult == DialogResult.Yes) {
762-
Properties.Settings.Default.HasCompletedTutorial = false;
763-
Properties.Settings.Default.ActionFilePath = "";
764-
Properties.Settings.Default.Save();
761+
try {
762+
if (dialogResult == DialogResult.Yes) {
763+
Properties.Settings.Default.HasCompletedTutorial = false;
764+
Properties.Settings.Default.ActionFilePath = "";
765+
Properties.Settings.Default.Save();
765766

766-
if (gettingStarted != null) {
767-
gettingStarted.Close();
768-
}
767+
if (gettingStarted != null) {
768+
gettingStarted.Close();
769+
}
769770

770-
ShowGettingStarted();
771+
ShowGettingStarted();
772+
}
773+
} catch {
774+
//Probably not in the main thread
771775
}
772776
}
773777

774-
public static string CheckPath() {
778+
public static string CheckPath(bool noDefaultCheck = false) {
775779
string path = currentLocation;
776780

777781
if (Properties.Settings.Default.ActionFilePath != "") {
@@ -790,9 +794,7 @@ public static string CheckPath() {
790794
}
791795
}
792796

793-
if (hasStarted && gettingStarted is null && path == currentLocation && !hasAskedForSetupAgain) {
794-
DoDebug("Did it here");
795-
797+
if (!noDefaultCheck && hasStarted && gettingStarted is null && path == currentLocation && !hasAskedForSetupAgain) {
796798
hasAskedForSetupAgain = true;
797799
DefaultPathIssue();
798800
}

AssistantComputerControl/SoftwareUpdater.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,19 @@ private static void FileDownloadedCallback(object sender, AsyncCompletedEventArg
213213

214214
if (!e.Cancelled) {
215215
//Download success
216-
Process.Start(targetLocation);
217-
MainProgram.DoDebug("New installer successfully downloaded and opened.");
218-
Application.Exit();
216+
try {
217+
if (File.Exists(targetLocation)) {
218+
Process.Start(targetLocation);
219+
MainProgram.DoDebug("New installer successfully downloaded and opened.");
220+
Application.Exit();
221+
} else {
222+
MainProgram.DoDebug("Downloaded file doesn't exist (new version)");
223+
MessageBox.Show("Failed to download new version of ACC. File doesn't exist", Translator.__("error", "general") + " | " + MainProgram.messageBoxTitle);
224+
}
225+
} catch (Exception ee) {
226+
MainProgram.DoDebug("Error occurred on open of new version; " + ee.Message);
227+
MessageBox.Show("Failed to open new version! Error is logged, please contact the developer on Discord!", Translator.__("error", "general") + " | " + MainProgram.messageBoxTitle);
228+
}
219229
} else {
220230
MainProgram.DoDebug("Failed to download new version of ACC. Error; " + e.Error);
221231
MessageBox.Show("Failed to download new version. Try again later!", Translator.__("error", "general") + " | " + MainProgram.messageBoxTitle);

AssistantComputerControl/app.manifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
compatibility.
1818
-->
1919
<!--<requestedExecutionLevel level="asInvoker" uiAccess="false" />-->
20-
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
20+
<!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
2121
</requestedPrivileges>
2222
<applicationRequestMinimum>
2323
<defaultAssemblyRequest permissionSetReference="Custom" />
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)