From 8505f2db961bd342255aa2e39bf67c0fa3abeb15 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:37:38 +0800 Subject: [PATCH] Optimize backup https://github.com/2dust/v2rayN/issues/5681 --- v2rayN/ServiceLib/Common/FileManager.cs | 4 ++++ v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/v2rayN/ServiceLib/Common/FileManager.cs b/v2rayN/ServiceLib/Common/FileManager.cs index 2e952bd8..266709d5 100644 --- a/v2rayN/ServiceLib/Common/FileManager.cs +++ b/v2rayN/ServiceLib/Common/FileManager.cs @@ -143,6 +143,10 @@ namespace ServiceLib.Common { continue; } + if (file.Extension == file.Name) + { + continue; + } string targetFilePath = Path.Combine(destinationDir, file.Name); file.CopyTo(targetFilePath); } diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index 9fca6a70..b1786fd2 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -147,7 +147,7 @@ namespace ServiceLib.ViewModels var configDirZipTemp = Utils.GetTempPath($"v2rayN_{DateTime.Now:yyyyMMddHHmmss}"); var configDirTemp = Path.Combine(configDirZipTemp, "guiConfigs"); - await Task.Run(() => FileManager.CopyDirectory(configDir, configDirTemp, true, "cache.db")); + await Task.Run(() => FileManager.CopyDirectory(configDir, configDirTemp, false, "cache.db")); var ret = await Task.Run(() => FileManager.CreateFromDirectory(configDirZipTemp, fileName)); await Task.Run(() => Directory.Delete(configDirZipTemp, true)); return ret;