Skip to content

Commit

Permalink
给update程序增加超时额外时间处理逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jul 23, 2024
1 parent 3e691bb commit 454cd3b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Update/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ public static void Main(string[] args)
Directory.CreateDirectory(directoryPath);

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Client (windows-latest, win-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (windows-latest, win-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (macOS-latest, osx-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (windows-latest, win-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Desktop (windows-latest, win-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (macOS-latest, osx-arm64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (macOS-latest, osx-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Client (windows-latest, win-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (macOS-latest, osx-arm64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-arm)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-arm)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-arm64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-arm64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Desktop (windows-latest, win-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-musl-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-musl-x64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-musl-arm)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-musl-arm)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-musl-arm64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.

Check warning on line 100 in Update/Program.cs

View workflow job for this annotation

GitHub Actions / Server (ubuntu-latest, linux-musl-arm64)

Possible null reference argument for parameter 'path' in 'DirectoryInfo Directory.CreateDirectory(string path)'.
}
bool dl_ok = false;
int time = 10;
do
{
dl_ok = DownloadFileAsync(item.Key, item.Value.FilePath);
time += 20;
} while (!dl_ok);
Console.WriteLine($" | 更新文件【{item.Value.Name}】成功");
i++;
Expand Down Expand Up @@ -259,7 +261,7 @@ public static string Get(string URL)
return str;
}

public static bool DownloadFileAsync(string url, string outputPath)
public static bool DownloadFileAsync(string url, string outputPath,long Time = 10)
{
int error_count = 0;
while (true)
Expand All @@ -281,7 +283,7 @@ public static bool DownloadFileAsync(string url, string outputPath)
try
{
HttpClient _httpClient = new HttpClient();
_httpClient.Timeout = new TimeSpan(0, 0, 10);
_httpClient.Timeout = new TimeSpan(0, 0, 10).Add(TimeSpan.FromSeconds(Time));
_httpClient.DefaultRequestHeaders.Referrer = new Uri("https://update5.ddtv.pro");
using var response = _httpClient.GetAsync(FileDownloadAddress, HttpCompletionOption.ResponseHeadersRead).Result;
response.EnsureSuccessStatusCode();
Expand Down

0 comments on commit 454cd3b

Please sign in to comment.