Skip to content

Commit

Permalink
change preferred cache dir (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX authored Dec 1, 2024
1 parent a10aca8 commit d9d1e41
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Runner.Sdk/GharunUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private static bool IsUsableLocalStorage(string localStorage) {
return localStorage != "" && !localStorage.Contains(' ') && !localStorage.Contains('"') && !localStorage.Contains('\'');
}

public static string GetLocalStorage() {
private static string GetLocalStorageLocation(string name) {
var localStorage = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
if(!IsUsableLocalStorage(localStorage)) {
localStorage = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
Expand All @@ -25,7 +25,20 @@ public static string GetLocalStorage() {
if(!IsUsableLocalStorage(localStorage)) {
localStorage = Path.GetTempPath();
}
return Path.GetFullPath(Path.Join(localStorage, "gharun"));
return Path.GetFullPath(Path.Join(localStorage, name));
}

public static string GetLocalStorage() {
string current = GetLocalStorageLocation("runner.server");
if(Directory.Exists(current)) {
return current;
}
string legacy = GetLocalStorageLocation("gharun");
if(Directory.Exists(legacy)) {
return legacy;
}
Directory.CreateDirectory(current);
return current;
}

public static string GetHostOS() {
Expand Down

0 comments on commit d9d1e41

Please sign in to comment.