refactor(oss): 摘两支零调用件+并档八格前缀守卫,可读性棘轮 973→958
红因:961→973 那 12 行来自 950f379d 的 download-endpoint 修复(真实增量,
不回退它)。本轮按 ops BACKLOG 口径把这一格真降回基线以下,不动
docs/readability-baseline.json、不 --write。
两条降法都刻意避开 catch 面,免得撞上 CatchSilence 的 RETHROW 下限:
1) 摘五棵树零调用件 uploadTaskScopePayload/uploadTaskParsedPayload
(自 54ee3f304/7e1974a68 引入,正本通道早已是
TransientPayloadStorageService.store("task-scope"|"task-parsed", …),
测试也直接吃 uploadText+拼好的 key,两处方法名在 main/test/前端/ops
全树零命中,无反射点名、无 XML/YML 绑定)。
2) 软件版本族四格与教程族守卫那八处逐字同形的 objectKey 前缀检查并成
requirePrefixedObjectKey(objectKey, prefix, what)。异常类型与消息文本
逐字不变(what + " objectKey must start with " + prefix 拼出的就是原来
那两句),requireTutorialKey 保留为具名守卫转调公共件。
门禁读数:mvn -o test-compile rc=0;定向 120 例/0 红/0 错/0 skip
(OssStorageService/InternalAudio/DownloadUrlNonExpiring/SoftwareVersion
四支业务测试+CatchSilence/SourceScan/SqlLayering/TaskStatusVocabulary/
ArchitectureBoundary/TaskLifecycleDebt 六把守门尺,后两格证明本笔没动
catch 账与状态字面量账);ops 面 test_readability_ratchet 9 passed。
This commit is contained in:
+11
-26
@@ -196,9 +196,7 @@ public class OssStorageService {
|
||||
* 服务端自己的读写走 internal-endpoint 那张 client,两者不能合用一张。
|
||||
*/
|
||||
public String presignSoftwareVersionUpload(String objectKey, int expirySeconds) {
|
||||
if (objectKey == null || !objectKey.startsWith(SOFTWARE_VERSION_PREFIX)) {
|
||||
throw new IllegalArgumentException("software version objectKey must start with " + SOFTWARE_VERSION_PREFIX);
|
||||
}
|
||||
requirePrefixedObjectKey(objectKey, SOFTWARE_VERSION_PREFIX, "software version");
|
||||
try {
|
||||
return presignClient().getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
||||
.method(Method.PUT)
|
||||
@@ -213,9 +211,7 @@ public class OssStorageService {
|
||||
|
||||
/** 返回软件版本对象的字节数;对象不存在返回 -1(直传完成后由服务端核对大小是否超限)。 */
|
||||
public long softwareVersionObjectSize(String objectKey) {
|
||||
if (objectKey == null || !objectKey.startsWith(SOFTWARE_VERSION_PREFIX)) {
|
||||
throw new IllegalArgumentException("software version objectKey must start with " + SOFTWARE_VERSION_PREFIX);
|
||||
}
|
||||
requirePrefixedObjectKey(objectKey, SOFTWARE_VERSION_PREFIX, "software version");
|
||||
try {
|
||||
var stat = buildClient().statObject(StatObjectArgs.builder()
|
||||
.bucket(publicClientBucket())
|
||||
@@ -234,9 +230,7 @@ public class OssStorageService {
|
||||
|
||||
/** 生成软件版本对象的公开下载 URL(与历史 file_url 同构:path-style client 桶)。 */
|
||||
public String getSoftwareVersionDownloadUrl(String objectKey) {
|
||||
if (objectKey == null || !objectKey.startsWith(SOFTWARE_VERSION_PREFIX)) {
|
||||
throw new IllegalArgumentException("software version objectKey must start with " + SOFTWARE_VERSION_PREFIX);
|
||||
}
|
||||
requirePrefixedObjectKey(objectKey, SOFTWARE_VERSION_PREFIX, "software version");
|
||||
return softwareVersionPublicUrl(objectKey);
|
||||
}
|
||||
|
||||
@@ -254,9 +248,7 @@ public class OssStorageService {
|
||||
|
||||
/** 删除软件版本对象(client 桶);确认环节发现超限等异常时清理残留,避免公共桶悬挂大对象。 */
|
||||
public void removeSoftwareVersionObject(String objectKey) {
|
||||
if (objectKey == null || !objectKey.startsWith(SOFTWARE_VERSION_PREFIX)) {
|
||||
throw new IllegalArgumentException("software version objectKey must start with " + SOFTWARE_VERSION_PREFIX);
|
||||
}
|
||||
requirePrefixedObjectKey(objectKey, SOFTWARE_VERSION_PREFIX, "software version");
|
||||
try {
|
||||
buildClient().removeObject(RemoveObjectArgs.builder()
|
||||
.bucket(publicClientBucket())
|
||||
@@ -324,8 +316,13 @@ public class OssStorageService {
|
||||
}
|
||||
|
||||
private void requireTutorialKey(String objectKey) {
|
||||
if (objectKey == null || !objectKey.startsWith(TUTORIAL_PREFIX)) {
|
||||
throw new IllegalArgumentException("tutorial objectKey must start with " + TUTORIAL_PREFIX);
|
||||
requirePrefixedObjectKey(objectKey, TUTORIAL_PREFIX, "tutorial");
|
||||
}
|
||||
|
||||
/** objectKey 前缀守卫:软件版本族与教程族八格同款,只是前缀与文案里的名字不同。 */
|
||||
private void requirePrefixedObjectKey(String objectKey, String prefix, String what) {
|
||||
if (objectKey == null || !objectKey.startsWith(prefix)) {
|
||||
throw new IllegalArgumentException(what + " objectKey must start with " + prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,18 +481,6 @@ public class OssStorageService {
|
||||
}
|
||||
}
|
||||
|
||||
public String uploadTaskScopePayload(String moduleType, Long taskId, String scopeHash, String content) {
|
||||
String normalizedScopeHash = scopeHash == null || scopeHash.isBlank() ? UUID.randomUUID().toString() : scopeHash;
|
||||
String objectKey = String.format("task-scope/%s/%s/%s.json", normalizeModuleType(moduleType), taskId, normalizedScopeHash);
|
||||
return uploadText(objectKey, content);
|
||||
}
|
||||
|
||||
public String uploadTaskParsedPayload(String moduleType, Long taskId, String scopeHash, String content) {
|
||||
String normalizedScopeHash = scopeHash == null || scopeHash.isBlank() ? UUID.randomUUID().toString() : scopeHash;
|
||||
String objectKey = String.format("task-parsed/%s/%s/%s.json", normalizeModuleType(moduleType), taskId, normalizedScopeHash);
|
||||
return uploadText(objectKey, content);
|
||||
}
|
||||
|
||||
public String readObjectAsString(String value) {
|
||||
StorageLocation location = resolveStorageLocation(value);
|
||||
if (location == null) {
|
||||
|
||||
Reference in New Issue
Block a user