File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1111 <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.3.1" />
1212 <PackageReference Include =" SixLabors.ImageSharp" Version =" 1.0.0-beta0002" />
1313 <PackageReference Include =" PdfSharp" Version =" 1.50.4845-RC2a" NoWarn =" NU1701" />
14+ <PackageReference Include =" Mono.Posix.NETStandard" Version =" 1.0.0" />
1415 </ItemGroup >
1516 <ItemGroup >
1617 <Folder Include =" Issues\" />
Original file line number Diff line number Diff line change 11using System ;
22using System . IO ;
3+ using System . Runtime . InteropServices ;
34using System . Threading . Tasks ;
45using Xunit ;
56using Xunit . Abstractions ;
@@ -32,6 +33,12 @@ public async Task ShouldDownloadAndExtractLinuxBinary()
3233 revisionInfo = await browserFetcher . DownloadAsync ( 123456 ) ;
3334 Assert . True ( revisionInfo . Local ) ;
3435 Assert . Equal ( "LINUX BINARY\n " , File . ReadAllText ( revisionInfo . ExecutablePath ) ) ;
36+
37+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) || RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
38+ {
39+ Mono . Unix . Native . Syscall . stat ( revisionInfo . ExecutablePath , out var stat ) ;
40+ Assert . Equal ( BrowserFetcher . BrowserPermissionsInLinux , stat . st_mode & BrowserFetcher . BrowserPermissionsInLinux ) ;
41+ }
3542 Assert . Equal ( new [ ] { 123456 } , browserFetcher . LocalRevisions ( ) ) ;
3643 browserFetcher . Remove ( 123456 ) ;
3744 Assert . Empty ( browserFetcher . LocalRevisions ( ) ) ;
Original file line number Diff line number Diff line change 88using System . Threading . Tasks ;
99using System . Net ;
1010using System . IO . Compression ;
11+ using Mono . Unix . Native ;
1112
1213namespace PuppeteerSharp
1314{
@@ -33,6 +34,13 @@ public class BrowserFetcher
3334 { Platform . Win64 , "{0}/chromium-browser-snapshots/Win_x64/{1}/chrome-win32.zip" }
3435 } ;
3536
37+ internal static readonly FilePermissions BrowserPermissionsInLinux =
38+ FilePermissions . S_IRWXU |
39+ FilePermissions . S_IRGRP |
40+ FilePermissions . S_IXGRP |
41+ FilePermissions . S_IROTH |
42+ FilePermissions . S_IXOTH ;
43+
3644 /// <summary>
3745 /// Default chromiumg revision.
3846 /// </summary>
@@ -164,7 +172,7 @@ public async Task<RevisionInfo> DownloadAsync(int revision)
164172
165173 if ( new DirectoryInfo ( folderPath ) . Exists )
166174 {
167- return null ;
175+ return RevisionInfo ( revision ) ;
168176 }
169177
170178 var downloadFolder = new DirectoryInfo ( DownloadsFolder ) ;
@@ -195,7 +203,13 @@ public async Task<RevisionInfo> DownloadAsync(int revision)
195203
196204 new FileInfo ( zipPath ) . Delete ( ) ;
197205
198- return RevisionInfo ( revision ) ;
206+ var revisionInfo = RevisionInfo ( revision ) ;
207+
208+ if ( revisionInfo != null && ( GetCurrentPlatform ( ) == Platform . Linux || GetCurrentPlatform ( ) == Platform . MacOS ) )
209+ {
210+ Syscall . chmod ( revisionInfo . ExecutablePath , BrowserPermissionsInLinux ) ;
211+ }
212+ return revisionInfo ;
199213 }
200214
201215 /// <summary>
Original file line number Diff line number Diff line change @@ -42,5 +42,6 @@ Changes
4242 <PackageReference Include =" System.Net.Http" Version =" 4.3.3" />
4343 <PackageReference Include =" Microsoft.AspNetCore.WebUtilities" Version =" 2.0.2" />
4444 <PackageReference Include =" System.Threading.Tasks.Extensions" Version =" 4.5.1" />
45+ <PackageReference Include =" Mono.Posix.NETStandard" Version =" 1.0.0" />
4546 </ItemGroup >
4647</Project >
You can’t perform that action at this time.
0 commit comments