From d0c6d57283f4a5bc16db2dfd97d2eb3c737aaad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Sat, 31 Oct 2026 06:22:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(storage):=20=E6=8C=89=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E6=96=B9=E9=80=89=E6=8B=A9=E6=95=B4=E5=BA=93=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=AF=BB=E5=9D=80=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ internal/librarystack/stack.go | 2 +- internal/librarystack/stack_test.go | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 internal/librarystack/stack_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index fdb516e..2ce5697 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 开发快照(云对象存储寻址兼容) + +### Fixed + +- 整库发布与恢复按存储提供方选择寻址方式:MinIO 保留路径式,OSS/S3 使用虚拟主机式,不再因强制路径式而被 OSS 拒绝资源上传。 + ## 开发快照(跨库分块序列分配) ### Fixed diff --git a/internal/librarystack/stack.go b/internal/librarystack/stack.go index f20abe5..0ea3788 100644 --- a/internal/librarystack/stack.go +++ b/internal/librarystack/stack.go @@ -83,7 +83,7 @@ func scopeConfigOf(config appconfig.Config, scope string) (scopeConfig, error) { Region: config.LibraryProductionS3Region, Bucket: config.LibraryProductionS3Bucket, AccessKeyID: config.LibraryProductionS3AccessKey, SecretAccessKey: config.LibraryProductionS3SecretKey, Secure: strings.HasPrefix(config.LibraryProductionS3Endpoint, "https://"), - ForcePathStyle: true, MaxObjectBytes: 256 * 1024 * 1024, + ForcePathStyle: config.LibraryProductionS3Provider == "minio", MaxObjectBytes: 256 * 1024 * 1024, }, }, nil } diff --git a/internal/librarystack/stack_test.go b/internal/librarystack/stack_test.go new file mode 100644 index 0000000..a19c982 --- /dev/null +++ b/internal/librarystack/stack_test.go @@ -0,0 +1,21 @@ +package librarystack + +import ( + "knowledge-governance/internal/appconfig" + "testing" +) + +func TestObjectAddressingMatchesProvider(t *testing.T) { + for _, provider := range []string{"oss", "s3", "minio"} { + t.Run(provider, func(t *testing.T) { + config := appconfig.Config{LibraryProductionDatabaseURL: "configured", LibraryProductionElasticURL: "configured", LibraryProductionTenantID: 1, LibraryProductionInternalKB: "kb-target", LibraryProductionS3Endpoint: "https://storage.example", LibraryProductionS3Bucket: "test-bucket", LibraryProductionS3AccessKey: "fixture", LibraryProductionS3SecretKey: "fixture", LibraryProductionS3Provider: provider} + scope, err := scopeConfigOf(config, "internal") + if err != nil { + t.Fatal(err) + } + if scope.s3.ForcePathStyle != (provider == "minio") { + t.Fatalf("provider %s: ForcePathStyle=%v", provider, scope.s3.ForcePathStyle) + } + }) + } +}