mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-07 12:16:04 +00:00
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:
parent
432fd39df2
commit
c4be361f95
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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(() =>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user