Skip to content

Commit

Permalink
Project: Create crash directory when writing crash backup
Browse files Browse the repository at this point in the history
  • Loading branch information
mat1jaczyyy committed Oct 17, 2019
1 parent 4d11743 commit f7678d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Apollo/Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ public static Project Project {
set {
_project?.Dispose();

if ((_project = value) == null) File.Delete(Program.CrashProject);
else {
if ((_project = value) == null) {
if (Directory.Exists(Program.CrashDir))
File.Delete(Program.CrashProject);

} else {
_project.WriteCrashBackup();

ProjectLoaded?.Invoke();
Expand Down
6 changes: 5 additions & 1 deletion Apollo/Elements/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ public int Page {
}
}

public async void WriteCrashBackup() => await WriteFile(null, Program.CrashProject, false);
public async void WriteCrashBackup() {
if (!Directory.Exists(Program.CrashDir)) Directory.CreateDirectory(Program.CrashDir);

await WriteFile(null, Program.CrashProject, false);
}

public async Task<bool> WriteFile(Window sender, string path = null, bool store = true) {
if (path == null) path = FilePath;
Expand Down

0 comments on commit f7678d0

Please sign in to comment.