Compare commits

..

No commits in common. "master" and "2.0.0.1" have entirely different histories.

8 changed files with 35 additions and 65 deletions

View File

@ -19,8 +19,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 8
dotnet-quality: 'preview'
dotnet-version: '6.0.x'
- name: Restore
env:

View File

@ -18,8 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 8
dotnet-quality: 'preview'
dotnet-version: '6.0.x'
- name: Restore
env:

View File

@ -1,12 +1,6 @@
# Atlassian Downloader - Changelog
## 2.x
* `2.0.0.2` - minor update:
* Added `maxRetries (default: 5)` and `delayBetweenRetries (default: 2500, milliseconds)` args, to redownload file if connection will be reset.
* Updated dependencies.
* `2.0.0.1` - minor update:
* Fix default output dir, enable nullables, fix compiler warnings #43
* Remove redundant parameters from publish profiles #42
* `2.0.0.0` - migrated to `dotnet8` and updated libs.
* code optimized by [@kasthack](https://github.com/kasthack).
* reworked build scripts via `cli` and `vs`.

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2009 EpicMorg
Copyright (c) 2018-2023 EpicMorg: Main
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -213,43 +213,31 @@ internal class DownloaderService : IHostedService
private async Task DownloadFile(ResponseItem file, string outputFile, CancellationToken cancellationToken)
{
for (int attempt = 1; attempt <= options.MaxRetries; attempt++)
if (!string.IsNullOrEmpty(file.Md5))
{
if (!string.IsNullOrEmpty(file.Md5))
{
File.WriteAllText(outputFile + ".md5", file.Md5);
}
File.WriteAllText(outputFile + ".md5", file.Md5);
}
try
{
using var outputStream = File.OpenWrite(outputFile);
using var request = await this.client.GetStreamAsync(file.ZipUrl, cancellationToken).ConfigureAwait(false);
await request.CopyToAsync(outputStream, cancellationToken).ConfigureAwait(false);
}
catch (Exception downloadEx)
{
this.logger.LogError(downloadEx, "Failed to download file \"{uri}\" to \"{outputFile}\".", file.ZipUrl, outputFile);
try
{
using var outputStream = File.OpenWrite(outputFile);
using var request = await this.client.GetStreamAsync(file.ZipUrl, cancellationToken).ConfigureAwait(false);
await request.CopyToAsync(outputStream, cancellationToken).ConfigureAwait(false);
File.Delete(outputFile);
}
catch (Exception downloadEx)
catch (Exception removeEx)
{
this.logger.LogError(downloadEx, "Attempt {attempt} failed to download file \"{uri}\" to \"{outputFile}\".", attempt, file.ZipUrl, outputFile);
if (attempt == options.MaxRetries)
{
this.logger.LogError(downloadEx, "Failed to download file \"{uri}\" to \"{outputFile}\".", file.ZipUrl, outputFile);
try
{
File.Delete(outputFile);
}
catch (Exception removeEx)
{
this.logger.LogError(removeEx, "Failed to remove incomplete file \"{outputFile}\".", outputFile);
}
throw;
}
else
{
await Task.Delay(options.DelayBetweenRetries, cancellationToken).ConfigureAwait(false);
}
this.logger.LogError(removeEx, "Failed to remove incomplete file \"{outputFile}\".", outputFile);
}
this.logger.LogInformation("File \"{uri}\" successfully downloaded to \"{outputFile}\".", file.ZipUrl, outputFile);
}
this.logger.LogInformation("File \"{uri}\" successfully downloaded to \"{outputFile}\".", file.ZipUrl, outputFile);
}
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously

View File

@ -8,7 +8,4 @@ public record DownloaderOptions(
bool Version,
string? ProductVersion,
bool SkipFileCheck,
string UserAgent,
int MaxRetries,
int DelayBetweenRetries
) { }
string UserAgent) { }

View File

@ -24,8 +24,6 @@ public class Program
/// <param name="productVersion">Override target version to download some product. Advice: Use it with "customFeed".</param>
/// <param name="skipFileCheck">Skip compare of file sizes if a local file already exists. Existing file will be skipped to check and redownload.</param>
/// <param name="userAgent">Set custom user agent via this feature flag.</param>
/// <param name="maxRetries">Set custom count of download retries.</param>
/// <param name="delayBetweenRetries">Set custom delay between retries (in milliseconds).</param>
static async Task Main(
string? outputDir = default,
Uri[]? customFeed = null,
@ -33,8 +31,6 @@ public class Program
bool about = false,
string? productVersion = null,
bool skipFileCheck = false,
int maxRetries = 5,
int delayBetweenRetries = 2500,
string userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0") => await
Host
.CreateDefaultBuilder()
@ -64,9 +60,7 @@ public class Program
about,
productVersion,
skipFileCheck,
userAgent,
maxRetries,
delayBetweenRetries))
userAgent))
.AddHttpClient())
.RunConsoleAsync()
.ConfigureAwait(false);

View File

@ -12,7 +12,6 @@
<!--build props-->
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<ApplicationIcon>favicon.ico</ApplicationIcon>
@ -27,25 +26,25 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/EpicMorg/atlassian-downloader</RepositoryUrl>
<PackageTags>atlassian, donwloader, epicmorg</PackageTags>
<AssemblyVersion>2.0.0.2</AssemblyVersion>
<FileVersion>2.0.0.2</FileVersion>
<Version>2.0.0.2</Version>
<Copyright>EpicMorg 2024</Copyright>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<Version>2.0.0.0</Version>
<Copyright>EpicMorg 2023</Copyright>
<Product>Atlassian Downloader</Product>
<Company>EpicMorg</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RootNamespace>EpicMorg.Atlassian.Downloader</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.1-dev-10354" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.2-dev-00546" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.2.0-dev-00918" />
<PackageReference Include="Serilog" Version="3.1.0-dev-02078" />
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.4.0-alpha.22272.1" />
<None Include="..\README.md">
<Pack>True</Pack>