Refactor downloaders to use generic options and unify logic
Replaces specialized binary and HTML downloaders with a generic, options-driven UnitDownloader and UnitFragmentDownloader pattern. Introduces UnitDownloaderOptions and builder classes for flexible configuration, updates interfaces and method signatures to support progress reporting, and removes redundant binary-specific classes. Updates Playwright and Stealth downloaders to use the new generic base, and adds improved error handling and reporting. Also updates dependency versions and makes minor API consistency improvements across the Fluent and Models layers.
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Beam.Models {
|
||||
public class ByteDocument(string filename, byte[] content, Encoding? encoding = null) : Document(filename, encoding) {
|
||||
public byte[] Content { get; set; } = content;
|
||||
public class ByteDocument : Document {
|
||||
public ByteDocument(string filename, byte[] content, Encoding? encoding = null) : base(filename, encoding) {
|
||||
Content = content;
|
||||
}
|
||||
|
||||
public ByteDocument(string filename, Memory<byte> content, Encoding? encoding = null) :
|
||||
base(filename, encoding) {
|
||||
Content = content;
|
||||
}
|
||||
|
||||
public Memory<byte> Content { get; set; }
|
||||
|
||||
public override byte[] ToBytes() {
|
||||
return Content;
|
||||
return Content.ToArray();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Encoding.GetString(Content);
|
||||
return Encoding.GetString(Content.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Beam.Models {
|
||||
public struct DownloadReport : IDownloadReport {
|
||||
// TODO implement download report
|
||||
public long BytesDownloaded { get; init; }
|
||||
public long? BytesRemaining { get; init; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user