mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-14 08:20:42 +08:00
优化手动执行模式:支持忽略执行周期规则的单任务运行
- 新增 IGNORE_EXECUTION_RULES 环境变量,用于标记手动运行单个任务时忽略执行周期/进度限制 - run_script_now 在手动运行单个任务时设置该标记,并保留原始任务索引用于日志显示 - do_save 支持 ignore_execution_rules 参数,单任务手动运行时直接跳过执行周期与进度判断 - 保持手动运行 ALL 和定时任务的执行周期/进度规则不变,避免影响现有功能
This commit is contained in:
parent
b420029771
commit
1ca3230153
@ -1855,8 +1855,12 @@ def run_script_now():
|
||||
if tasklist:
|
||||
process_env["TASKLIST"] = json.dumps(tasklist, ensure_ascii=False)
|
||||
# 添加原始任务索引的环境变量
|
||||
if len(tasklist) == 1 and 'original_index' in request.json:
|
||||
process_env["ORIGINAL_TASK_INDEX"] = str(request.json['original_index'])
|
||||
if len(tasklist) == 1:
|
||||
# 单任务手动运行:前端传入 original_index,用于日志展示
|
||||
if 'original_index' in request.json:
|
||||
process_env["ORIGINAL_TASK_INDEX"] = str(request.json['original_index'])
|
||||
# 单任务手动运行应忽略执行周期和任务进度限制(包括自动模式下进度100%也要执行)
|
||||
process_env["IGNORE_EXECUTION_RULES"] = "1"
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
|
||||
@ -4466,7 +4466,7 @@ def do_sign(account):
|
||||
print()
|
||||
|
||||
|
||||
def do_save(account, tasklist=[]):
|
||||
def do_save(account, tasklist=[], ignore_execution_rules=False):
|
||||
print(f"🧩 载入插件")
|
||||
plugins, CONFIG_DATA["plugins"], task_plugins_config = Config.load_plugins(
|
||||
CONFIG_DATA.get("plugins", {})
|
||||
@ -4479,6 +4479,9 @@ def do_save(account, tasklist=[]):
|
||||
sent_notices = set()
|
||||
|
||||
def is_time(task):
|
||||
# 若为手动单任务运行并明确要求忽略执行周期/进度限制,则始终执行
|
||||
if ignore_execution_rules:
|
||||
return True
|
||||
# 获取任务的执行周期模式,优先使用任务自身的execution_mode,否则使用系统配置的execution_mode
|
||||
execution_mode = task.get("execution_mode") or CONFIG_DATA.get("execution_mode", "manual")
|
||||
|
||||
@ -5892,9 +5895,12 @@ def main():
|
||||
print(f"===============转存任务===============")
|
||||
# 任务列表
|
||||
if tasklist_from_env:
|
||||
do_save(accounts[0], tasklist_from_env)
|
||||
# 若通过环境变量传入任务列表,视为手动运行,可由外层控制是否忽略执行周期/进度限制
|
||||
ignore_execution_rules = os.environ.get("IGNORE_EXECUTION_RULES", "").lower() in ["1", "true", "yes"]
|
||||
do_save(accounts[0], tasklist_from_env, ignore_execution_rules=ignore_execution_rules)
|
||||
else:
|
||||
do_save(accounts[0], CONFIG_DATA.get("tasklist", []))
|
||||
# 定时任务或命令行全量运行,始终遵循执行周期/进度规则
|
||||
do_save(accounts[0], CONFIG_DATA.get("tasklist", []), ignore_execution_rules=False)
|
||||
print()
|
||||
# 通知
|
||||
if NOTIFYS:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user