Added checking for updates
This commit is contained in:
parent
cc15863e81
commit
5ec6525257
19 changed files with 1231 additions and 100 deletions
37
Services/IDownloadService.cs
Normal file
37
Services/IDownloadService.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
namespace MossyUpdater.Services
|
||||
{
|
||||
public interface IDownloadService
|
||||
{
|
||||
Task<DownloadResult> DownloadFileAsync(string url, string destinationPath, IProgress<DownloadProgress>? progress = null, CancellationToken cancellationToken = default);
|
||||
Task<FileUpdateInfo> CheckForUpdatesAsync(string url, string localFilePath, CancellationToken cancellationToken = default);
|
||||
void UnblockFile(string filePath);
|
||||
}
|
||||
|
||||
public class DownloadResult
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public long BytesDownloaded { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadProgress
|
||||
{
|
||||
public long BytesReceived { get; set; }
|
||||
public long? TotalBytes { get; set; }
|
||||
public double ProgressPercentage => TotalBytes.HasValue && TotalBytes > 0
|
||||
? (double)BytesReceived / TotalBytes.Value * 100
|
||||
: 0;
|
||||
public string Status { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class FileUpdateInfo
|
||||
{
|
||||
public bool UpdateAvailable { get; set; }
|
||||
public DateTime? RemoteLastModified { get; set; }
|
||||
public DateTime? LocalLastModified { get; set; }
|
||||
public long? RemoteSize { get; set; }
|
||||
public long? LocalSize { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue