Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Don't retry Aware detector unless there is an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Jan 6, 2022
1 parent b8a0d84 commit 717922a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Squirrel/Internal/SquirrelAwareExecutableDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ public static List<string> GetAllSquirrelAwareApps(string directory, int minimum
};

for (int i = 0; i < 3; i++) {
bool error = false;
foreach (var fn in detectors) {
try {
var v = fn(exePath);
if (v != null) return v;
} catch {
error = true;
// do not throw, otherwise other detectors will not run
}
}

if (!error) {
// we tried all the detectors and none of them threw, so we don't need to retry
break;
}

// retry 3 times with 100ms delay
Thread.Sleep(100);
}
Expand All @@ -63,7 +71,7 @@ public static List<string> GetAllSquirrelAwareApps(string directory, int minimum
return StringFileInfo.ReadVersionInfo(executable, out var vi)
.Where(i => i.Key == SQUIRREL_AWARE_KEY)
.Where(i => int.TryParse(i.Value, out var _))
.Select(i => (int?)int.Parse(i.Value))
.Select(i => (int?) int.Parse(i.Value))
.FirstOrDefault(i => i > 0);
}

Expand Down

0 comments on commit 717922a

Please sign in to comment.