mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-03 17:57:03 +00:00
feat: 支持“仅生成不上传”模式,优化定时同步与上传流程
- 新增云配置同步策略:定时任务在缺少 GitHub Token 时会跳过需要上传的条目,但仍执行“仅本地生成”(upload=false)的条目 - 同步逻辑支持 `upload: false`:配置仍会生成和更新时间,但不上传到 Gist,并会清理旧的远端 URL - 上传批次改为仅处理可上传条目;当无可上传条目时直接提示并跳过上传 - 同步日志和通知区分“上传成功/仅生成未上传/因缺少 token 跳过”,统计更准确 - 删除配置的远端删除条件调整为更合理:没有远端 URL 且仅本地运行的条目不会再尝试远端删除 - 新增/扩展测试覆盖了: - cron 同步策略判断 - 批量上传时跳过 `upload: false` - 单条同步时仅更新运行时间且不上传 - 无远端 URL 时删除行为
This commit is contained in:
8 files changed
+519
-42
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { hasGistSyncCredentials } from '@/utils/gist';
|
||||
|
||||
function shouldUploadArtifactForCron(artifact) {
|
||||
return artifact?.upload !== false;
|
||||
}
|
||||
|
||||
function resolveCronArtifactSyncPolicy({ artifacts = [], settings = {} } = {}) {
|
||||
const hasUploadCredentials = hasGistSyncCredentials(settings);
|
||||
const shouldSync = artifacts.some((artifact) => artifact.sync);
|
||||
const shouldProduceWithUpload = artifacts.some(
|
||||
(artifact) => artifact.sync && shouldUploadArtifactForCron(artifact),
|
||||
);
|
||||
const shouldProduceWithoutUpload = artifacts.some(
|
||||
(artifact) => artifact.sync && !shouldUploadArtifactForCron(artifact),
|
||||
);
|
||||
|
||||
return {
|
||||
canUpload: hasUploadCredentials || !shouldProduceWithUpload,
|
||||
shouldRun:
|
||||
shouldSync && (hasUploadCredentials || shouldProduceWithoutUpload),
|
||||
};
|
||||
}
|
||||
|
||||
function shouldSkipCronArtifactWithoutUploadCredentials(
|
||||
artifact,
|
||||
{ canUpload },
|
||||
) {
|
||||
return !canUpload && shouldUploadArtifactForCron(artifact);
|
||||
}
|
||||
|
||||
export {
|
||||
resolveCronArtifactSyncPolicy,
|
||||
shouldSkipCronArtifactWithoutUploadCredentials,
|
||||
};
|
||||
Reference in new issue
Block a user