Fixed the issue of readonly custom config

Fixed the issue where importing read-only custom files would cause the service to fail to start
pull/4409/head
zhaojingshi 2023-11-18 10:22:37 +08:00
parent f3f3dc1951
commit 6b62623615
1 changed files with 3 additions and 1 deletions

View File

@ -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);
}
}
}
}