File tree Expand file tree Collapse file tree
YoutubeExplode.Converter.Tests/Utils/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- using System . IO ;
1+ using System ;
2+ using System . IO ;
23
34namespace YoutubeExplode . Converter . Tests . Utils . Extensions ;
45
56internal static class FileExtensions
67{
78 extension ( File )
89 {
9- public static bool ContainsBytes ( string filePath , byte [ ] data )
10+ public static bool ContainsBytes ( string filePath , ReadOnlySpan < byte > data )
1011 {
1112 using var stream = File . OpenRead ( filePath ) ;
1213 using var reader = new BinaryReader ( stream ) ;
Original file line number Diff line number Diff line change 11using System . IO ;
22using System . Net . Http ;
3+ using System . Threading ;
34using System . Threading . Tasks ;
45
56namespace YoutubeExplode . Converter . Tests . Utils . Extensions ;
@@ -8,15 +9,24 @@ internal static class HttpExtensions
89{
910 extension ( HttpClient http )
1011 {
11- public async Task DownloadAsync ( string url , string filePath )
12+ public async Task DownloadAsync (
13+ string url ,
14+ string filePath ,
15+ CancellationToken cancellationToken = default
16+ )
1217 {
13- using var response = await http . GetAsync ( url , HttpCompletionOption . ResponseHeadersRead ) ;
18+ using var response = await http . GetAsync (
19+ url ,
20+ HttpCompletionOption . ResponseHeadersRead ,
21+ cancellationToken
22+ ) ;
23+
1424 response . EnsureSuccessStatusCode ( ) ;
1525
16- await using var source = await response . Content . ReadAsStreamAsync ( ) ;
26+ await using var source = await response . Content . ReadAsStreamAsync ( cancellationToken ) ;
1727 await using var destination = File . Create ( filePath ) ;
1828
19- await source . CopyToAsync ( destination ) ;
29+ await source . CopyToAsync ( destination , cancellationToken ) ;
2030 }
2131 }
2232}
You can’t perform that action at this time.
0 commit comments