Skip to content
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

change preferred cache dir #454

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading