Use local Synology for test
This commit is contained in:
parent
c562e75a97
commit
5e52e2dd8c
3 changed files with 17 additions and 21 deletions
|
|
@ -22,11 +22,11 @@
|
||||||
<PackageReference Include="Serilog" Version="4.0.1" />
|
<PackageReference Include="Serilog" Version="4.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.38.0" />
|
<PackageReference Include="SharpCompress" Version="0.38.0" />
|
||||||
<PackageReference Include="Synology.Api.Client" Version="0.2.68" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\RdtClient.Data\RdtClient.Data.csproj" />
|
<ProjectReference Include="..\RdtClient.Data\RdtClient.Data.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\Synology.Api.Client\src\Synology.Api.Client\Synology.Api.Client.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ public class DownloadStationDownloader : IDownloader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var retryCount = 0;
|
var retryCount = 0;
|
||||||
while (retryCount < 5)
|
while (retryCount < 5)
|
||||||
{
|
{
|
||||||
|
|
@ -106,8 +105,6 @@ public class DownloadStationDownloader : IDownloader
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await CheckFolderOrCreate(path);
|
|
||||||
|
|
||||||
var createResult = await _synologyClient
|
var createResult = await _synologyClient
|
||||||
.DownloadStationApi()
|
.DownloadStationApi()
|
||||||
.TaskEndpoint()
|
.TaskEndpoint()
|
||||||
|
|
@ -115,32 +112,25 @@ public class DownloadStationDownloader : IDownloader
|
||||||
|
|
||||||
_logger.Debug($"Added download to DownloadStation, received ID {_gid}");
|
_logger.Debug($"Added download to DownloadStation, received ID {_gid}");
|
||||||
|
|
||||||
if (createResult.Success)
|
_gid = createResult.TaskId?.FirstOrDefault();
|
||||||
|
if (_gid == null) _gid = await GetGidFromUri();
|
||||||
|
|
||||||
|
if (_gid != null)
|
||||||
{
|
{
|
||||||
_gid = await GetGidFromUri();
|
_logger.Debug($"Download with ID {_gid} found in DownloadStation");
|
||||||
if (_gid != null)
|
return _gid;
|
||||||
{
|
|
||||||
_logger.Debug($"Download with ID {_gid} found in DownloadStation");
|
|
||||||
return _gid;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retryCount++;
|
|
||||||
_logger.Debug($"Task not found in DownloadStation after creat Sucess. Retrying {retryCount}/{RetryCount}");
|
|
||||||
await Task.Delay(retryCount * 1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retryCount++;
|
retryCount++;
|
||||||
_logger.Debug($"Error starting download: {createResult.Error.Code}. Retrying {retryCount}/{RetryCount}");
|
_logger.Error($"Task not found in DownloadStation after creat Sucess. Retrying {retryCount}/{RetryCount}");
|
||||||
await Task.Delay(retryCount * 1000);
|
await Task.Delay(retryCount * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
retryCount++;
|
retryCount++;
|
||||||
_logger.Debug($"Error starting download: {e.Message}. Retrying {retryCount}/{RetryCount}");
|
_logger.Error($"Error starting download: {e.Message}. Retrying {retryCount}/{RetryCount}");
|
||||||
await Task.Delay(retryCount * 1000);
|
await Task.Delay(retryCount * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +141,7 @@ public class DownloadStationDownloader : IDownloader
|
||||||
private async Task<String?> GetGidFromUri()
|
private async Task<String?> GetGidFromUri()
|
||||||
{
|
{
|
||||||
var tasks = await _synologyClient.DownloadStationApi().TaskEndpoint().ListAsync();
|
var tasks = await _synologyClient.DownloadStationApi().TaskEndpoint().ListAsync();
|
||||||
return tasks.Tasks.FirstOrDefault(t => t.Additional?.Detail?.Uri == _uri)?.Id;
|
return tasks.Task.FirstOrDefault(t => t.Additional?.Detail?.Uri == _uri)?.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Pause()
|
public async Task Pause()
|
||||||
|
|
@ -181,7 +171,7 @@ public class DownloadStationDownloader : IDownloader
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task.Status == "finished")
|
if (task.Status == DownloadStationTaskStatus.Finished)
|
||||||
{
|
{
|
||||||
DownloadComplete?.Invoke(this, new() { Error = null });
|
DownloadComplete?.Invoke(this, new() { Error = null });
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RdtClient.Service", "RdtCli
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RdtClient.Data", "RdtClient.Data\RdtClient.Data.csproj", "{92EF8817-AD73-4301-93BD-745D7D61DD74}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RdtClient.Data", "RdtClient.Data\RdtClient.Data.csproj", "{92EF8817-AD73-4301-93BD-745D7D61DD74}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synology.Api.Client", "..\..\Synology.Api.Client\src\Synology.Api.Client\Synology.Api.Client.csproj", "{FDAAD49C-126C-4612-81C2-3CEB6D7A1105}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -27,6 +29,10 @@ Global
|
||||||
{92EF8817-AD73-4301-93BD-745D7D61DD74}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{92EF8817-AD73-4301-93BD-745D7D61DD74}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{92EF8817-AD73-4301-93BD-745D7D61DD74}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{92EF8817-AD73-4301-93BD-745D7D61DD74}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{92EF8817-AD73-4301-93BD-745D7D61DD74}.Release|Any CPU.Build.0 = Release|Any CPU
|
{92EF8817-AD73-4301-93BD-745D7D61DD74}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FDAAD49C-126C-4612-81C2-3CEB6D7A1105}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FDAAD49C-126C-4612-81C2-3CEB6D7A1105}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FDAAD49C-126C-4612-81C2-3CEB6D7A1105}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FDAAD49C-126C-4612-81C2-3CEB6D7A1105}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue