TrangaSettings export after change
This commit is contained in:
parent
0f0902c932
commit
ed4bdb5b33
@ -363,9 +363,7 @@ public class TaskManager
|
|||||||
private void ExportDataAndSettings()
|
private void ExportDataAndSettings()
|
||||||
{
|
{
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Exporting settings to {settings.settingsFilePath}");
|
logger?.WriteLine(this.GetType().ToString(), $"Exporting settings to {settings.settingsFilePath}");
|
||||||
while(IsFileInUse(settings.settingsFilePath))
|
settings.ExportSettings();
|
||||||
Thread.Sleep(50);
|
|
||||||
File.WriteAllText(settings.settingsFilePath, JsonConvert.SerializeObject(settings));
|
|
||||||
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Exporting tasks to {settings.tasksFilePath}");
|
logger?.WriteLine(this.GetType().ToString(), $"Exporting tasks to {settings.tasksFilePath}");
|
||||||
while(IsFileInUse(settings.tasksFilePath))
|
while(IsFileInUse(settings.tasksFilePath))
|
||||||
|
@ -43,6 +43,29 @@ public class TrangaSettings
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ExportSettings()
|
||||||
|
{
|
||||||
|
if (File.Exists(settingsFilePath))
|
||||||
|
{
|
||||||
|
bool inUse = true;
|
||||||
|
while (inUse)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using FileStream stream = new (settingsFilePath, FileMode.Open, FileAccess.Read, FileShare.None);
|
||||||
|
stream.Close();
|
||||||
|
inUse = false;
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
inUse = true;
|
||||||
|
Thread.Sleep(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File.WriteAllText(settingsFilePath, JsonConvert.SerializeObject(this));
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateSettings(UpdateField field, Logger? logger = null, params string[] values)
|
public void UpdateSettings(UpdateField field, Logger? logger = null, params string[] values)
|
||||||
{
|
{
|
||||||
switch (field)
|
switch (field)
|
||||||
@ -81,6 +104,7 @@ public class TrangaSettings
|
|||||||
newLunaSea.SendNotification("Success!", "LunaSea was added to Tranga!");
|
newLunaSea.SendNotification("Success!", "LunaSea was added to Tranga!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ExportSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum UpdateField { DownloadLocation, Komga, Kavita, Gotify, LunaSea}
|
public enum UpdateField { DownloadLocation, Komga, Kavita, Gotify, LunaSea}
|
||||||
|
Loading…
Reference in New Issue
Block a user