fix: store本地优先+脚本保存七牛云失败不阻塞
This commit is contained in:
@@ -271,13 +271,12 @@ public class AdminController {
|
|||||||
scriptPath = scriptPath.replace("/approved/", "/pending/");
|
scriptPath = scriptPath.replace("/approved/", "/pending/");
|
||||||
}
|
}
|
||||||
config.setScriptStoragePath(scriptPath);
|
config.setScriptStoragePath(scriptPath);
|
||||||
// 保存到七牛云+本地缓存
|
siteConfigMapper.updateById(config);
|
||||||
try {
|
try {
|
||||||
storageService.store(scriptPath, script);
|
storageService.store(scriptPath, script);
|
||||||
siteConfigMapper.updateById(config);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to save script: configId={}, path={}", configId, scriptPath, e);
|
log.error("Failed to upload script to Qiniu: path={}", scriptPath, e);
|
||||||
return ApiResponse.error(500, "保存失败: " + e.getMessage());
|
// Qiniu 失败不阻塞,本地已有
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Config script saved: id={}, siteId={}", configId, config.getSiteId());
|
log.info("Config script saved: id={}, siteId={}", configId, config.getSiteId());
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ public class CachedStorageService implements StorageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void store(String path, String content) {
|
public void store(String path, String content) {
|
||||||
|
// 先本地,保证不丢
|
||||||
|
local.store(path, content);
|
||||||
|
// 再七牛云
|
||||||
if (isQiniuMode()) {
|
if (isQiniuMode()) {
|
||||||
qiniu.store(path, content);
|
qiniu.store(path, content);
|
||||||
try { local.store(path, content); } catch (Exception ignored) {}
|
|
||||||
} else {
|
|
||||||
local.store(path, content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user