From 7e350b64baa417274d22e70e5db996423d99d52c Mon Sep 17 00:00:00 2001 From: Kevin Zhang <45326534+taooceros@users.noreply.github.com> Date: Thu, 26 Jan 2023 23:59:19 -0600 Subject: [PATCH 1/3] Fix Error of loading backup when original file doesn't exists --- Flow.Launcher.Infrastructure/Storage/JsonStorage.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs b/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs index 43e7ddab7..3b873524a 100644 --- a/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs +++ b/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs @@ -77,7 +77,11 @@ namespace Flow.Launcher.Infrastructure.Storage if (data != null) { Log.Info($"|JsonStorage.Load|Failed to load settings.json, {BackupFilePath} restored successfully"); - File.Replace(BackupFilePath, FilePath, null); + + if(File.Exists(FilePath) + File.Replace(BackupFilePath, FilePath, null); + else + File.Copy(BackupFilePath, FilePath); return data; } From 52fcc68448fb6bd34395db5bb9d67d1d6a3a43c9 Mon Sep 17 00:00:00 2001 From: Kevin Zhang <45326534+taooceros@users.noreply.github.com> Date: Fri, 27 Jan 2023 00:01:47 -0600 Subject: [PATCH 2/3] Move over Copy Move might be better since Replace delete the original file --- Flow.Launcher.Infrastructure/Storage/JsonStorage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs b/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs index 3b873524a..892f5f227 100644 --- a/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs +++ b/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs @@ -81,7 +81,7 @@ namespace Flow.Launcher.Infrastructure.Storage if(File.Exists(FilePath) File.Replace(BackupFilePath, FilePath, null); else - File.Copy(BackupFilePath, FilePath); + File.Move(BackupFilePath, FilePath); return data; } From 4e1d59bde328210a8f6b7524751a2de17d438208 Mon Sep 17 00:00:00 2001 From: Kevin Zhang <45326534+taooceros@users.noreply.github.com> Date: Fri, 27 Jan 2023 09:38:39 -0600 Subject: [PATCH 3/3] fix the missing parathesis --- Flow.Launcher.Infrastructure/Storage/JsonStorage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs b/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs index 892f5f227..45456ddeb 100644 --- a/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs +++ b/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs @@ -78,7 +78,7 @@ namespace Flow.Launcher.Infrastructure.Storage { Log.Info($"|JsonStorage.Load|Failed to load settings.json, {BackupFilePath} restored successfully"); - if(File.Exists(FilePath) + if(File.Exists(FilePath)) File.Replace(BackupFilePath, FilePath, null); else File.Move(BackupFilePath, FilePath);