Compare commits

..

1 commit

Author SHA1 Message Date
JieXu
790025718d
Merge 6a98ee377d into 29a5abf4d6 2025-09-12 00:41:39 +08:00
2 changed files with 22 additions and 51 deletions

View file

@ -857,55 +857,6 @@ public class Utils
return false; return false;
} }
public static bool IsPackagedInstall()
{
try
{
if (IsWindows() || IsOSX())
{
return false;
}
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPIMAGE")))
{
return true;
}
var exePath = GetExePath();
var baseDir = string.IsNullOrEmpty(exePath) ? StartupPath() : Path.GetDirectoryName(exePath) ?? "";
var p = baseDir.Replace('\\', '/');
if (string.IsNullOrEmpty(p))
{
return false;
}
if (p.Contains("/.mount_", StringComparison.Ordinal))
{
return true;
}
if (p.StartsWith("/opt/v2rayN", StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (p.StartsWith("/usr/lib/v2rayN", StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (p.StartsWith("/usr/share/v2rayN", StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
catch
{
}
return false;
}
private static async Task<string?> GetLinuxUserId() private static async Task<string?> GetLinuxUserId()
{ {
var arg = new List<string>() { "-c", "id -u" }; var arg = new List<string>() { "-c", "id -u" };

View file

@ -61,9 +61,29 @@ public class CheckUpdateViewModel : MyReactiveObject
CheckUpdateModels.Add(GetCheckUpdateModel(_geo)); CheckUpdateModels.Add(GetCheckUpdateModel(_geo));
} }
private static bool IsPackagedInstall()
{
try
{
if (Utils.IsWindows())
return false;
if (!string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("APPIMAGE")))
return true;
var sp = Utils.StartupPath()?.Replace('\\', '/');
if (!string.IsNullOrEmpty(sp) && sp.StartsWith("/opt/v2rayN", StringComparison.Ordinal))
return true;
var procPath = System.Environment.ProcessPath;
var procDir = string.IsNullOrEmpty(procPath) ? "" : System.IO.Path.GetDirectoryName(procPath)?.Replace('\\', '/');
if (!string.IsNullOrEmpty(procDir) && procDir.StartsWith("/opt/v2rayN", StringComparison.Ordinal))
return true;
}
catch { }
return false;
}
private CheckUpdateModel GetCheckUpdateModel(string coreType) private CheckUpdateModel GetCheckUpdateModel(string coreType)
{ {
if (coreType == _v2rayN && Utils.IsPackagedInstall()) if (coreType == _v2rayN && IsPackagedInstall())
{ {
return new() return new()
{ {
@ -114,7 +134,7 @@ public class CheckUpdateViewModel : MyReactiveObject
} }
else if (item.CoreType == _v2rayN) else if (item.CoreType == _v2rayN)
{ {
if (Utils.IsPackagedInstall()) if (IsPackagedInstall())
{ {
await UpdateView(_v2rayN, "Not Support"); await UpdateView(_v2rayN, "Not Support");
continue; continue;