From f38d1ce0b0307f2fa9f75df3e6b1e43958a09550 Mon Sep 17 00:00:00 2001 From: LittleFish-233 Date: Fri, 5 May 2023 12:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=AD=98=E8=AF=8D=E6=9D=A1=E7=BC=A9?= =?UTF-8?q?=E7=95=A5=E5=9B=BE=E5=88=B0=E5=85=AC=E5=85=B1=E5=9B=BE=E5=BA=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/Files/FileService.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CnGalWebSite/CnGalWebSite.APIServer/Application/Files/FileService.cs b/CnGalWebSite/CnGalWebSite.APIServer/Application/Files/FileService.cs index 07f829b9f..1b9d05589 100644 --- a/CnGalWebSite/CnGalWebSite.APIServer/Application/Files/FileService.cs +++ b/CnGalWebSite/CnGalWebSite.APIServer/Application/Files/FileService.cs @@ -122,6 +122,30 @@ public async Task TransferMainImagesToPublic(int maxCount) } + entries = await _entryRepository.GetAll().Where(s => string.IsNullOrWhiteSpace(s.Thumbnail) == false && s.IsHidden == false && string.IsNullOrWhiteSpace(s.Name) == false && s.MainPicture.Contains("?") == false && s.MainPicture.Contains("default") == false) + .OrderBy(s => s.Id) + .Take(maxCount).ToListAsync(); + + foreach (var item in entries) + { + try + { + var temp = await TransferDepositFile(item.Thumbnail); + if (string.IsNullOrWhiteSpace(temp) == false) + { + item.Thumbnail = temp; + await _entryRepository.UpdateAsync(item); + _logger.LogInformation("转存 词条 - {name}({id}) 缩略图到 tucang.cc 图床,链接替换为:{url}", item.Name, item.Id, item.Thumbnail); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "转存词条 - {Name}({Id}) 缩略图失败", item.Name, item.Id); + } + + } + + var articles = await _articleRepository.GetAll().Where(s => string.IsNullOrWhiteSpace(s.MainPicture) == false && s.IsHidden == false && string.IsNullOrWhiteSpace(s.Name) == false && s.MainPicture.Contains("?") == false && s.MainPicture.Contains("default") == false) .OrderBy(s => s.Id) .Take(maxCount).ToListAsync();