Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return whether the permissions fix was executed successfully #2754

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/PuppeteerSharp/BrowserData/InstalledBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ internal InstalledBrowser(Cache cache, SupportedBrowser browser, string buildId,
/// </summary>
public Platform Platform { get; set; }

/// <summary>
/// Whether the permissions have been fixed in the browser.
/// If Puppeteer executed the command to fix the permissions, this will be true.
/// If Puppeteer failed to fix the permissions, this will be false.
/// If the platform does not require permissions to be fixed, this will be null.
/// </summary>
public bool? PermissionsFixed { get; internal set; }

/// <summary>
/// Revision platform.
/// </summary>
Expand Down
13 changes: 9 additions & 4 deletions lib/PuppeteerSharp/BrowserFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@

if (!assemblyDirectory.Exists || !File.Exists(Path.Combine(assemblyDirectory.FullName, assemblyName)))
{
var assemblyLocation = assembly.Location;

Check warning on line 177 in lib/PuppeteerSharp/BrowserFetcher.cs

View workflow job for this annotation

GitHub Actions / Demo Project (windows-2022)

PuppeteerSharp.BrowserFetcher.GetBrowsersLocation(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.

if (string.IsNullOrEmpty(assemblyLocation))
{
Expand Down Expand Up @@ -250,7 +250,7 @@
if (new DirectoryInfo(outputPath).Exists)
{
var existingBrowser = new InstalledBrowser(cache, browser, buildId, Platform);
RunSetup(existingBrowser);
existingBrowser.PermissionsFixed = RunSetup(existingBrowser);
return existingBrowser;
}

Expand All @@ -267,11 +267,11 @@
new FileInfo(archivePath).Delete();

var installedBrowser = new InstalledBrowser(cache, browser, buildId, Platform);
RunSetup(installedBrowser);
installedBrowser.PermissionsFixed = RunSetup(installedBrowser);
return installedBrowser;
}

private void RunSetup(InstalledBrowser installedBrowser)
private bool? RunSetup(InstalledBrowser installedBrowser)
{
// On Windows for Chrome invoke setup.exe to configure sandboxes.
if (
Expand All @@ -285,7 +285,7 @@

if (!File.Exists(setupExePath))
{
return;
return false;
}

using var process = new Process();
Expand All @@ -295,12 +295,17 @@
process.StartInfo.UseShellExecute = false;
process.Start();
process.WaitForExit();

return true;
}
catch (Exception ex)
{
_logger?.LogError(ex, "Failed to run setup.exe");
return false;
}
}

return null;
}

private async Task InstallDmgAsync(string dmgPath, string folderPath)
Expand Down
8 changes: 4 additions & 4 deletions lib/PuppeteerSharp/PuppeteerSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<Description>Headless Browser .NET API</Description>
<PackageId>PuppeteerSharp</PackageId>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageVersion>19.0.1</PackageVersion>
<ReleaseVersion>19.0.1</ReleaseVersion>
<AssemblyVersion>19.0.1</AssemblyVersion>
<FileVersion>19.0.1</FileVersion>
<PackageVersion>19.0.2</PackageVersion>
<ReleaseVersion>19.0.2</ReleaseVersion>
<AssemblyVersion>19.0.2</AssemblyVersion>
<FileVersion>19.0.2</FileVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
<DebugType>embedded</DebugType>
Expand Down
Loading