From 6b626236156e503a92a971d0425dec650bd523dd Mon Sep 17 00:00:00 2001 From: zhaojingshi Date: Sat, 18 Nov 2023 10:22:37 +0800 Subject: [PATCH] Fixed the issue of readonly custom config Fixed the issue where importing read-only custom files would cause the service to fail to start --- v2rayN/v2rayN/Handler/CoreConfigHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/Handler/CoreConfigHandler.cs b/v2rayN/v2rayN/Handler/CoreConfigHandler.cs index c0dc712e..95334ee9 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigHandler.cs @@ -80,6 +80,7 @@ namespace v2rayN.Handler if (File.Exists(fileName)) { + File.SetAttributes(fileName, FileAttributes.Normal); //If the file has a read-only attribute, direct deletion will fail File.Delete(fileName); } @@ -94,6 +95,7 @@ namespace v2rayN.Handler return -1; } File.Copy(addressFileName, fileName); + File.SetAttributes(fileName, FileAttributes.Normal); //Copy will keep the attributes of addressFileName, so we need to add write permissions to fileName just in case of addressFileName is a read-only file. //check again if (!File.Exists(fileName)) @@ -153,4 +155,4 @@ namespace v2rayN.Handler return coreConfigV2ray.GenerateClientSpeedtestConfigString(selecteds, out msg); } } -} \ No newline at end of file +}