feat: add Empty method and fix link handling
Added a static `Empty` method to `DownloadEnumerable` for creating an empty instance. Updated link handling in `SequentialDownloader` to use `AbsoluteUri` instead of `ToString()`, ensuring correct link representation. These changes improve usability and ensure consistency in link formatting.
This commit is contained in:
@@ -10,5 +10,8 @@ namespace Beam {
|
|||||||
|
|
||||||
public IAsyncEnumerator<Ordered<T>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
|
public IAsyncEnumerator<Ordered<T>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
|
||||||
=> Download;
|
=> Download;
|
||||||
|
|
||||||
|
public static DownloadEnumerable<T> Empty()
|
||||||
|
=> new(Array.Empty<Ordered<T>>().ToAsyncEnumerable().GetAsyncEnumerator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,17 +44,17 @@ namespace Beam {
|
|||||||
List<Ordered<string>> links = [];
|
List<Ordered<string>> links = [];
|
||||||
|
|
||||||
//Logger?.LogInformation("MoveNextAsync() \n\t -> Links.Current = {} ", LinksEnumerator.Current.Link.AbsoluteUri);
|
//Logger?.LogInformation("MoveNextAsync() \n\t -> Links.Current = {} ", LinksEnumerator.Current.Link.AbsoluteUri);
|
||||||
links.Add(new Ordered<string>(LinksEnumerator.Current.Link.ToString(), LastOrder++));
|
links.Add(new Ordered<string>(LinksEnumerator.Current.Link.AbsoluteUri, LastOrder++));
|
||||||
|
|
||||||
while (LinksEnumerator.MoveNext() && LinksEnumerator.Current != SourceLink.InvalidLink && links.Count < idealLinkCount)
|
while (LinksEnumerator.MoveNext() && LinksEnumerator.Current != SourceLink.InvalidLink && links.Count < idealLinkCount)
|
||||||
links.Add(new Ordered<string>(LinksEnumerator.Current.Link.ToString(), LastOrder++));
|
links.Add(new Ordered<string>(LinksEnumerator.Current.Link.AbsoluteUri, LastOrder++));
|
||||||
//Logger?.LogInformation("MoveNextAsync() \n\t -> links.Count = {} ", links.Count);
|
//Logger?.LogInformation("MoveNextAsync() \n\t -> links.Count = {} ", links.Count);
|
||||||
if (links.Count == 0) {
|
if (links.Count == 0) {
|
||||||
Logger?.LogInformation("Out of links!");
|
Logger?.LogInformation("Out of links!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (links.Any((x) => x.Data == SourceLink.InvalidLink.Link.ToString()))
|
if (links.Any((x) => x.Data == SourceLink.InvalidLink.Link.AbsoluteUri))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var (result, downloadedT) = await unit.TryDownload(
|
var (result, downloadedT) = await unit.TryDownload(
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ namespace Beam {
|
|||||||
/// Produces a deep copy whose <see cref="Segments"/> and contained collections are detached from the original.
|
/// Produces a deep copy whose <see cref="Segments"/> and contained collections are detached from the original.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SourceLinkBuilder Clone()
|
public SourceLinkBuilder Clone()
|
||||||
=> new SourceLinkBuilder(Protocol, Host) {
|
=> new SourceLinkBuilder(Host, Protocol) {
|
||||||
Segments = [.. Segments.Select(static x => x.Clone())]
|
Segments = [.. Segments.Select(static x => x.Clone())]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<Title>Beam</Title>
|
<Title>Beam</Title>
|
||||||
<Authors>aeqw89</Authors>
|
<Authors>aeqw89</Authors>
|
||||||
<Company>qwsdcvghyu</Company>
|
<Company>qwsdcvghyu</Company>
|
||||||
<Version>1.3.2</Version>
|
<Version>1.3.6</Version>
|
||||||
<Description>A library for downloading internet resources</Description>
|
<Description>A library for downloading internet resources</Description>
|
||||||
<PackageProjectUrl>https://github.com/qwsdcvghyu89/Beam</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/qwsdcvghyu89/Beam</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/qwsdcvghyu89/Beam</RepositoryUrl>
|
<RepositoryUrl>https://github.com/qwsdcvghyu89/Beam</RepositoryUrl>
|
||||||
|
|||||||
Reference in New Issue
Block a user