From 07f43538dfd5c6cad5d7fc31485fa703d72640b4 Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 22 Jan 2025 01:17:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=99=E5=85=A5=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/shared/utils.ts | 5 ++++- shell/share.sh | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/back/shared/utils.ts b/back/shared/utils.ts index 8cd27478..59f9ce33 100644 --- a/back/shared/utils.ts +++ b/back/shared/utils.ts @@ -1,7 +1,7 @@ import { lock } from 'proper-lockfile'; import os from 'os'; import path from 'path'; -import { writeFile, open } from 'fs/promises'; +import { writeFile, open, chmod } from 'fs/promises'; import { fileExist } from '../config/util'; function getUniqueLockPath(filePath: string) { @@ -35,5 +35,8 @@ export async function writeFileWithLock( lockfilePath, }); await writeFile(filePath, content, { encoding: 'utf8', ...options }); + if (options?.mode) { + await chmod(filePath, options.mode); + } await release(); } diff --git a/shell/share.sh b/shell/share.sh index 342788d5..3dbb214d 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -474,7 +474,7 @@ handle_task_end() { local end_timestamp=$(format_timestamp "$time_format" "$etime") local diff_time=$(($end_timestamp - $begin_timestamp)) local suffix="" - [[ "$MANUAL" == "true" ]] && suffix="(手动停止)" + [[ "${MANUAL:=}" == "true" ]] && suffix="(手动停止)" [[ "$diff_time" == 0 ]] && diff_time=1 @@ -484,7 +484,7 @@ handle_task_end() { error_message=", 任务状态更新失败(${error})" fi fi - echo -e "\n## 执行结束$suffix... $end_time 耗时 $diff_time 秒${error_message}     " + echo -e "\n## 执行结束$suffix... $end_time 耗时 $diff_time 秒${error_message:=}     " } init_env