From aafc679e45cabe204a4ca852ae82395e6621eb4f Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 18 Mar 2026 15:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E4=B8=B4?= =?UTF-8?q?=E6=97=B6token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Helper/OSSService.cs | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs index 166f810a6..d600988e6 100644 --- a/IRaCIS.Core.Application/Helper/OSSService.cs +++ b/IRaCIS.Core.Application/Helper/OSSService.cs @@ -1860,6 +1860,8 @@ public class OSSService(IOptionsMonitor options, public ObjectStoreDTO GetObjectStoreTempToken(string? domain = null, bool? isGetAllTempToken = null) { + + string objectStoreUse = string.Empty; //如果传递了域名,并且打开了存储同步,根据域名使用的具体存储覆盖之前的配置,否则就用固定的配置 if (ObjectStoreServiceOptions.IsOpenStoreSync && domain.IsNotNullOrEmpty()) { @@ -1868,13 +1870,17 @@ public class OSSService(IOptionsMonitor options, var find = ObjectStoreServiceOptions.SyncConfigList.FirstOrDefault(t => t.Domain == userDomain); if (find != null) { - ObjectStoreServiceOptions.ObjectStoreUse = find.Primary; + objectStoreUse = find.Primary; } } + else + { + objectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse; + } - var objectStoreDTO = new ObjectStoreDTO() { ObjectStoreUse = ObjectStoreServiceOptions.ObjectStoreUse, IsOpenStoreSync = ObjectStoreServiceOptions.IsOpenStoreSync, SyncConfigList = ObjectStoreServiceOptions.SyncConfigList }; + var objectStoreDTO = new ObjectStoreDTO() { ObjectStoreUse = objectStoreUse, IsOpenStoreSync = ObjectStoreServiceOptions.IsOpenStoreSync, SyncConfigList = ObjectStoreServiceOptions.SyncConfigList }; - if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS" || isGetAllTempToken == true) + if (objectStoreUse == "AliyunOSS" || isGetAllTempToken == true) { var ossOptions = ObjectStoreServiceOptions.AliyunOSS; @@ -1922,11 +1928,11 @@ public class OSSService(IOptionsMonitor options, objectStoreDTO.AliyunOSS = tempToken; } - if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO") + if (objectStoreUse == "MinIO") { objectStoreDTO.MinIO = ObjectStoreServiceOptions.MinIO; } - if (ObjectStoreServiceOptions.ObjectStoreUse == "AWS" || isGetAllTempToken == true) + if (objectStoreUse == "AWS" || isGetAllTempToken == true) { var awsOptions = ObjectStoreServiceOptions.AWS; @@ -1972,6 +1978,10 @@ public class OSSService(IOptionsMonitor options, objectStoreDTO.AWS = tempToken; } + if (objectStoreUse.IsNullOrEmpty()) + { + throw new BusinessValidationFailedException("未定义的存储介质类型"); + } return objectStoreDTO; } @@ -2063,10 +2073,6 @@ public class OSSService(IOptionsMonitor options, throw new BusinessValidationFailedException("未定义的同步类型"); } } - catch (Exception ex) - { - Log.Error($"同步错误:{ex.Message}"); - } finally { // ⭐⭐⭐ 真正释放 HTTP 连接