mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-20 15:06:36 +00:00
fix: comprehensive Sora & GDrive code review fixes
P0 fixes: - StorageType: UploadFromURL now returns actual storageType, fixing GDrive tasks being incorrectly recorded as "s3" - Concurrency: selectAccount returns ReleaseFunc to caller, fixing premature slot release before task creation - Race condition: applyRecoveredToken uses copy-on-write for account.Credentials map to prevent concurrent write panic - GetCameoStatus: use direct HTTP call to populate missing fields (StatusMessage, InstructionSetHint, InstructionSet) - Frontend: progress bar uses reactive now.value instead of non-reactive Date.now() P1 fixes: - EditImage: pass req.Image through to CreateImageRequest - ListPending: add LIMIT 200 to prevent unbounded queries - Worker encapsulation: add ListPendingTasks/UpdateTask proxy methods to SoraTaskService, worker no longer accesses repo directly - Frontend polling: add retry counter (3 attempts) before giving up P2-P3 fixes: - QuotaBar: handle both quota_source and source field names - i18n: replace hardcoded Chinese labels in SoraPromptBar and example prompts in SoraGeneratePage with i18n keys - Fix regenrate → regenerate i18n typo - SoraMediaPreview: skip Escape handler when not visible - SoraGeneratePage: void handleGenerate promise in handleRetry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
f9695ca83f
commit
597c19e80b
18 files changed
+168
-81
No files matched your search
@@ -350,9 +350,10 @@ func (h *SoraClientHandler) storeMediaWithDegradation(
|
||||
if h.objectStorage != nil && h.objectStorage.Enabled(ctx) {
|
||||
keys := make([]string, 0, len(urls))
|
||||
var totalSize int64
|
||||
var actualStorageType string
|
||||
allOK := true
|
||||
for _, u := range urls {
|
||||
key, size, err := h.objectStorage.UploadFromURL(ctx, userID, u)
|
||||
key, size, st, err := h.objectStorage.UploadFromURL(ctx, userID, u)
|
||||
if err != nil {
|
||||
logger.LegacyPrintf("handler.sora_client", "[SoraClient] 对象存储上传失败 type=%s err=%v", h.objectStorage.StorageType(), err)
|
||||
allOK = false
|
||||
@@ -364,6 +365,7 @@ func (h *SoraClientHandler) storeMediaWithDegradation(
|
||||
}
|
||||
keys = append(keys, key)
|
||||
totalSize += size
|
||||
actualStorageType = st
|
||||
}
|
||||
if allOK && len(keys) > 0 {
|
||||
accessURLs := make([]string, 0, len(keys))
|
||||
@@ -378,7 +380,7 @@ func (h *SoraClientHandler) storeMediaWithDegradation(
|
||||
accessURLs = append(accessURLs, accessURL)
|
||||
}
|
||||
if allOK && len(accessURLs) > 0 {
|
||||
return accessURLs[0], accessURLs, h.objectStorage.StorageType(), keys, totalSize
|
||||
return accessURLs[0], accessURLs, actualStorageType, keys, totalSize
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -697,7 +699,7 @@ func (h *SoraClientHandler) SaveToStorage(c *gin.Context) {
|
||||
var totalSize int64
|
||||
|
||||
for _, sourceURL := range sourceURLs {
|
||||
objectKey, fileSize, uploadErr := h.objectStorage.UploadFromURL(c.Request.Context(), userID, sourceURL)
|
||||
objectKey, fileSize, _, uploadErr := h.objectStorage.UploadFromURL(c.Request.Context(), userID, sourceURL)
|
||||
if uploadErr != nil {
|
||||
if len(uploadedKeys) > 0 {
|
||||
_ = h.objectStorage.DeleteObjects(c.Request.Context(), uploadedKeys)
|
||||
|
||||
Reference in new issue
Block a user