Added checking for updates

This commit is contained in:
erik 2025-05-31 00:06:18 +02:00
parent cc15863e81
commit 5ec6525257
19 changed files with 1231 additions and 100 deletions

View 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; }
}
}