Skip to content

Commit de1090e

Browse files
committed
fix some issue mentioned by copilot
1 parent 42efcf6 commit de1090e

File tree

6 files changed

+42
-20
lines changed

6 files changed

+42
-20
lines changed

src/UniGetUI.Core.LanguageEngine/Assets/Languages/lang_en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@
504504
"The Missing Package Manager for macOS (or Linux).<br>Contains: <b>Formulae, Casks</b>": "The Missing Package Manager for macOS (or Linux).<br>Contains: <b>Formulae, Casks</b>",
505505
"The default package manager for Debian/Ubuntu-based Linux distributions.<br>Contains: <b>Debian/Ubuntu packages</b>": "The default package manager for Debian/Ubuntu-based Linux distributions.<br>Contains: <b>Debian/Ubuntu packages</b>",
506506
"The default package manager for RHEL/Fedora-based Linux distributions.<br>Contains: <b>RPM packages</b>": "The default package manager for RHEL/Fedora-based Linux distributions.<br>Contains: <b>RPM packages</b>",
507+
"The default package manager for Arch Linux and its derivatives.<br>Contains: <b>Arch Linux packages</b>": "The default package manager for Arch Linux and its derivatives.<br>Contains: <b>Arch Linux packages</b>",
507508
"Node JS's package manager. Full of libraries and other utilities that orbit the javascript world<br>Contains: <b>Node javascript libraries and other related utilities</b>": "Node JS's package manager. Full of libraries and other utilities that orbit the javascript world<br>Contains: <b>Node javascript libraries and other related utilities</b>",
508509
"Python's library manager. Full of python libraries and other python-related utilities<br>Contains: <b>Python libraries and related utilities</b>": "Python's library manager. Full of python libraries and other python-related utilities<br>Contains: <b>Python libraries and related utilities</b>",
509510
"PowerShell's package manager. Find libraries and scripts to expand PowerShell capabilities<br>Contains: <b>Modules, Scripts, Cmdlets</b>": "PowerShell's package manager. Find libraries and scripts to expand PowerShell capabilities<br>Contains: <b>Modules, Scripts, Cmdlets</b>",

src/UniGetUI.Core.Tools/Tools.cs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,20 @@ public static async Task CacheUACForCurrentProcess()
506506
_isCaching = true;
507507
Logger.Info("Caching admin rights for process id " + Environment.ProcessId);
508508

509-
// When using sudo on Linux, "-Av" validates/extends the timestamp via the
510-
// askpass helper — prompts once then caches for the sudo timeout (~15 min).
511-
// For gsudo on Windows (or pkexec fallback) use the gsudo cache protocol.
512-
string cacheArgs = Path.GetFileName(CoreData.ElevatorPath) == "sudo"
513-
? "-Av"
509+
var elevatorName = Path.GetFileName(CoreData.ElevatorPath);
510+
511+
// pkexec prompts on every invocation and has no caching protocol.
512+
if (elevatorName == "pkexec")
513+
{
514+
_isCaching = false;
515+
return;
516+
}
517+
518+
// sudo: -v validates/extends the cached timestamp.
519+
// Prepend -A only when the SUDO_ASKPASS helper is configured.
520+
// gsudo / UniGetUI Elevator.exe: use the gsudo cache protocol.
521+
string cacheArgs = elevatorName == "sudo"
522+
? (CoreData.ElevatorArgs.Contains("-A") ? "-Av" : "-v")
514523
: "cache on --pid " + Environment.ProcessId + " -d 1";
515524

516525
using Process p = new()
@@ -555,9 +564,17 @@ public static async Task ResetUACForCurrentProcess()
555564
"Resetting administrator rights cache for process id " + Environment.ProcessId
556565
);
557566

558-
// When using sudo on Linux, "-K" removes all cached timestamps.
559-
// For gsudo on Windows (or pkexec fallback) use the gsudo cache protocol.
560-
string resetArgs = Path.GetFileName(CoreData.ElevatorPath) == "sudo"
567+
var elevatorName = Path.GetFileName(CoreData.ElevatorPath);
568+
569+
// pkexec prompts on every invocation and has no caching protocol.
570+
if (elevatorName == "pkexec")
571+
{
572+
return;
573+
}
574+
575+
// sudo: -K removes all cached timestamps.
576+
// gsudo / UniGetUI Elevator.exe: use the gsudo cache protocol.
577+
string resetArgs = elevatorName == "sudo"
561578
? "-K"
562579
: "cache off --pid " + Environment.ProcessId;
563580

src/UniGetUI.PackageEngine.Managers.Apt/Helpers/AptPkgDetailsHelper.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics;
22
using UniGetUI.Core.IconEngine;
33
using UniGetUI.PackageEngine.Classes.Manager.BaseProviders;
4+
using UniGetUI.PackageEngine.Enums;
45
using UniGetUI.PackageEngine.Interfaces;
56
using UniGetUI.PackageEngine.ManagerClasses.Classes;
67

@@ -27,7 +28,7 @@ protected override void GetDetails_UnSafe(IPackageDetails details)
2728
};
2829

2930
IProcessTaskLogger logger = Manager.TaskLogger.CreateNew(
30-
Enums.LoggableTaskType.LoadPackageDetails, p);
31+
LoggableTaskType.LoadPackageDetails, p);
3132
p.Start();
3233

3334
// apt-cache show outputs key: value pairs, one per line.
@@ -138,13 +139,22 @@ protected override IReadOnlyList<Uri> GetScreenshots_UnSafe(IPackage package)
138139
},
139140
};
140141
p.Start();
141-
var firstPath = p.StandardOutput.ReadLine()?.Trim();
142-
p.WaitForExit();
143142

144-
if (firstPath is not null && Directory.Exists(firstPath))
145-
return firstPath;
143+
// Must drain all stdout before WaitForExit — packages with many files
144+
// will fill the pipe buffer and deadlock if we stop reading early.
145+
string? result = null;
146+
string? line;
147+
while ((line = p.StandardOutput.ReadLine()) is not null)
148+
{
149+
if (result is not null) continue;
150+
var path = line.Trim();
151+
if (Directory.Exists(path))
152+
result = path;
153+
}
146154

147-
return null;
155+
p.StandardError.ReadToEnd();
156+
p.WaitForExit();
157+
return result;
148158
}
149159

150160
protected override IReadOnlyList<string> GetInstallableVersions_UnSafe(IPackage package)

src/UniGetUI.PackageEngine.Managers.Apt/Helpers/AptPkgOperationHelper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using UniGetUI.Core.Logging;
21
using UniGetUI.PackageEngine.Classes.Manager.BaseProviders;
32
using UniGetUI.PackageEngine.Enums;
43
using UniGetUI.PackageEngine.Interfaces;
@@ -18,7 +17,6 @@ protected override IReadOnlyList<string> _getOperationParameters(
1817
{
1918
// apt always requires root — force elevation via InstallOptions (reference type, persists)
2019
options.RunAsAdministrator = true;
21-
Logger.Warn($"[Apt] Set RunAsAdministrator=true on options for package {package.Id}");
2220

2321
List<string> parameters =
2422
[

src/UniGetUI.PackageEngine.Managers.Dnf/Helpers/DnfPkgOperationHelper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using UniGetUI.Core.Logging;
21
using UniGetUI.PackageEngine.Classes.Manager.BaseProviders;
32
using UniGetUI.PackageEngine.Enums;
43
using UniGetUI.PackageEngine.Interfaces;
@@ -18,7 +17,6 @@ protected override IReadOnlyList<string> _getOperationParameters(
1817
{
1918
// dnf always requires root — force elevation via InstallOptions (reference type, persists)
2019
options.RunAsAdministrator = true;
21-
Logger.Warn($"[Dnf] Set RunAsAdministrator=true on options for package {package.Id}");
2220

2321
List<string> parameters =
2422
[

src/UniGetUI.PackageEngine.Managers.Pacman/Helpers/PacmanPkgOperationHelper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using UniGetUI.Core.Logging;
21
using UniGetUI.PackageEngine.Classes.Manager.BaseProviders;
32
using UniGetUI.PackageEngine.Enums;
43
using UniGetUI.PackageEngine.Interfaces;
@@ -18,7 +17,6 @@ protected override IReadOnlyList<string> _getOperationParameters(
1817
{
1918
// pacman always requires root — force elevation via InstallOptions (reference type, persists)
2019
options.RunAsAdministrator = true;
21-
Logger.Warn($"[Pacman] Set RunAsAdministrator=true on options for package {package.Id}");
2220

2321
List<string> parameters =
2422
[

0 commit comments

Comments
 (0)