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 连接