@whyour/qinglong 2.18.2-0 → 2.18.2-2
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 +1 -1
- package/sample/notify.js +5 -5
- package/static/build/shared/utils.js +18 -5
package/package.json
CHANGED
package/sample/notify.js
CHANGED
|
@@ -428,7 +428,7 @@ function tgBotNotify(text, desp) {
|
|
|
428
428
|
TG_PROXY_AUTH,
|
|
429
429
|
} = push_config;
|
|
430
430
|
if (TG_BOT_TOKEN && TG_USER_ID) {
|
|
431
|
-
|
|
431
|
+
let options = {
|
|
432
432
|
url: `${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`,
|
|
433
433
|
json: {
|
|
434
434
|
chat_id: `${TG_USER_ID}`,
|
|
@@ -442,20 +442,20 @@ function tgBotNotify(text, desp) {
|
|
|
442
442
|
};
|
|
443
443
|
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
|
444
444
|
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent');
|
|
445
|
-
const
|
|
445
|
+
const _options = {
|
|
446
446
|
keepAlive: true,
|
|
447
447
|
keepAliveMsecs: 1000,
|
|
448
448
|
maxSockets: 256,
|
|
449
449
|
maxFreeSockets: 256,
|
|
450
450
|
proxy: `http://${TG_PROXY_AUTH}${TG_PROXY_HOST}:${TG_PROXY_PORT}`,
|
|
451
451
|
};
|
|
452
|
-
const httpAgent = new HttpProxyAgent(
|
|
453
|
-
const httpsAgent = new HttpsProxyAgent(
|
|
452
|
+
const httpAgent = new HttpProxyAgent(_options);
|
|
453
|
+
const httpsAgent = new HttpsProxyAgent(_options);
|
|
454
454
|
const agent = {
|
|
455
455
|
http: httpAgent,
|
|
456
456
|
https: httpsAgent,
|
|
457
457
|
};
|
|
458
|
-
|
|
458
|
+
options.agent = agent;
|
|
459
459
|
}
|
|
460
460
|
$.post(options, (err, resp, data) => {
|
|
461
461
|
try {
|
|
@@ -1,26 +1,39 @@
|
|
|
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
|
-
|
|
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)(
|
|
12
|
-
const fileHandle = await (0, promises_1.open)(
|
|
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
|
|
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)(
|
|
36
|
+
await (0, promises_1.writeFile)(filePath, content, Object.assign({ encoding: 'utf8' }, options));
|
|
24
37
|
await release();
|
|
25
38
|
}
|
|
26
39
|
exports.writeFileWithLock = writeFileWithLock;
|