@whyour/qinglong 2.18.2-1 → 2.18.2-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "2.18.2-1",
3
+ "version": "2.18.2-3",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
package/shell/share.sh CHANGED
@@ -474,7 +474,7 @@ handle_task_end() {
474
474
  local end_timestamp=$(format_timestamp "$time_format" "$etime")
475
475
  local diff_time=$(($end_timestamp - $begin_timestamp))
476
476
  local suffix=""
477
- [[ "$MANUAL" == "true" ]] && suffix="(手动停止)"
477
+ [[ "${MANUAL:=}" == "true" ]] && suffix="(手动停止)"
478
478
 
479
479
  [[ "$diff_time" == 0 ]] && diff_time=1
480
480
 
@@ -484,7 +484,7 @@ handle_task_end() {
484
484
  error_message=", 任务状态更新失败(${error})"
485
485
  fi
486
486
  fi
487
- echo -e "\n## 执行结束$suffix... $end_time 耗时 $diff_time 秒${error_message}     "
487
+ echo -e "\n## 执行结束$suffix... $end_time 耗时 $diff_time 秒${error_message:=}     "
488
488
  }
489
489
 
490
490
  init_env
@@ -1,26 +1,42 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.writeFileWithLock = void 0;
4
7
  const proper_lockfile_1 = require("proper-lockfile");
8
+ const os_1 = __importDefault(require("os"));
9
+ const path_1 = __importDefault(require("path"));
5
10
  const promises_1 = require("fs/promises");
6
11
  const util_1 = require("../config/util");
7
- async function writeFileWithLock(path, content, options = {}) {
12
+ function getUniqueLockPath(filePath) {
13
+ const sanitizedPath = filePath
14
+ .replace(/[<>:"/\\|?*]/g, '_')
15
+ .replace(/^_/, '');
16
+ return path_1.default.join(os_1.default.tmpdir(), `${sanitizedPath}.ql_lock`);
17
+ }
18
+ async function writeFileWithLock(filePath, content, options = {}) {
8
19
  if (typeof options === 'string') {
9
20
  options = { encoding: options };
10
21
  }
11
- if (!(await (0, util_1.fileExist)(path))) {
12
- const fileHandle = await (0, promises_1.open)(path, 'w');
22
+ if (!(await (0, util_1.fileExist)(filePath))) {
23
+ const fileHandle = await (0, promises_1.open)(filePath, 'w');
13
24
  fileHandle.close();
14
25
  }
15
- const release = await (0, proper_lockfile_1.lock)(path, {
26
+ const lockfilePath = getUniqueLockPath(filePath);
27
+ const release = await (0, proper_lockfile_1.lock)(filePath, {
16
28
  retries: {
17
29
  retries: 10,
18
30
  factor: 2,
19
31
  minTimeout: 100,
20
32
  maxTimeout: 3000,
21
33
  },
34
+ lockfilePath,
22
35
  });
23
- await (0, promises_1.writeFile)(path, content, Object.assign({ encoding: 'utf8' }, options));
36
+ await (0, promises_1.writeFile)(filePath, content, Object.assign({ encoding: 'utf8' }, options));
37
+ if (options === null || options === void 0 ? void 0 : options.mode) {
38
+ await (0, promises_1.chmod)(filePath, options.mode);
39
+ }
24
40
  await release();
25
41
  }
26
42
  exports.writeFileWithLock = writeFileWithLock;