persist snapshot captures on disk

This commit is contained in:
Kang Yu 2024-08-27 17:21:34 -07:00
parent ef02d287d5
commit e8322d5a8a
2 changed files with 7 additions and 5 deletions

View file

@ -217,6 +217,9 @@ namespace PersistentWindows.Common
public void WriteDataDump() public void WriteDataDump()
{ {
if (!dumpDataWhenExit)
return;
DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>)); DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
using (XmlWriter xw = XmlWriter.Create(sb)) using (XmlWriter xw = XmlWriter.Create(sb))
@ -240,7 +243,7 @@ namespace PersistentWindows.Common
{ {
deadApps = (Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>)dcs.ReadObject(xr); deadApps = (Dictionary<string, Dictionary<IntPtr, List<ApplicationDisplayMetrics>>>)dcs.ReadObject(xr);
} }
File.Delete(Path.Combine(appDataFolder, windowPosDataFile)); //File.Delete(Path.Combine(appDataFolder, windowPosDataFile));
string path2 = Path.Combine(appDataFolder, snapshotTimeFile); string path2 = Path.Combine(appDataFolder, snapshotTimeFile);
if (!File.Exists(path2)) if (!File.Exists(path2))
@ -251,7 +254,7 @@ namespace PersistentWindows.Common
{ {
snapshotTakenTime = (Dictionary<string, Dictionary<int, DateTime>>)dcs2.ReadObject(xr); snapshotTakenTime = (Dictionary<string, Dictionary<int, DateTime>>)dcs2.ReadObject(xr);
} }
File.Delete(Path.Combine(appDataFolder, snapshotTimeFile)); //File.Delete(Path.Combine(appDataFolder, snapshotTimeFile));
} }
private void ReadDataDumpSafe() private void ReadDataDumpSafe()
@ -1972,7 +1975,7 @@ namespace PersistentWindows.Common
Log.Event("Snapshot {0} is captured", snapshotId); Log.Event("Snapshot {0} is captured", snapshotId);
} }
DumpSnapshotTakenTime(); WriteDataDump();
return true; return true;
} }

View file

@ -814,7 +814,6 @@ namespace PersistentWindows.SystrayShell
{ {
try try
{ {
if (pwp.dumpDataWhenExit)
pwp.WriteDataDump(); pwp.WriteDataDump();
} }
catch (Exception e) catch (Exception e)