Fix instance data survival time issue

The data in the Temp directory has a short retention period, posing a risk of data loss. Therefore, it has been changed to the AppData directory.
This commit is contained in:
Namhyeon Go 2025-02-20 12:57:53 +09:00
parent 432fd39df2
commit c4be361f95
3 changed files with 20 additions and 2 deletions

View File

@ -7,7 +7,7 @@ namespace WelsonJS.Launcher
{
public partial class InstancesForm : Form
{
private readonly string instancesRoot = Path.GetTempPath();
private string instancesRoot;
private string entryFileName;
private string scriptName;
@ -15,6 +15,7 @@ namespace WelsonJS.Launcher
{
InitializeComponent();
instancesRoot = Program.GetAppDataPath();
entryFileName = "bootstrap.bat";
}

View File

@ -69,7 +69,7 @@ namespace WelsonJS.Launcher
private void ExtractAndRun(string filePath)
{
instanceId = Guid.NewGuid().ToString();
workingDirectory = Path.Combine(Path.GetTempPath(), instanceId);
workingDirectory = Path.Combine(Program.GetAppDataPath(), instanceId);
scriptName = textBox1.Text;
Task.Run(() =>

View File

@ -88,5 +88,22 @@ namespace WelsonJS.Launcher
return path;
}
public static string GetAppDataPath()
{
string path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"welsonjs"
);
Directory.CreateDirectory(path);
if (!Directory.Exists(path))
{
throw new IOException("Failed to create directory: " + path);
}
return path;
}
}
}