xcraft-core-utils 4.12.1 → 4.13.0
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/lib/arrayCollector.js +4 -0
- package/lib/files.js +1 -1
- package/lib/locks.js +10 -12
- package/package.json +1 -1
package/lib/arrayCollector.js
CHANGED
package/lib/files.js
CHANGED
|
@@ -171,7 +171,7 @@ exports.getMimeType = async function (filePath) {
|
|
|
171
171
|
const result = magic.detect(filePath, magic.flags | MagicFlags.MAGIC_MIME);
|
|
172
172
|
let [mime, charset] = result.split(';');
|
|
173
173
|
mime = mime.trim();
|
|
174
|
-
charset = charset.trim().split('=')[1];
|
|
174
|
+
charset = charset ? charset.trim().split('=')[1] : '';
|
|
175
175
|
return {mime, charset};
|
|
176
176
|
} finally {
|
|
177
177
|
FileMagic.close();
|
package/lib/locks.js
CHANGED
|
@@ -70,31 +70,29 @@ class RecursiveMutex extends Mutex {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
class GetMutex {
|
|
73
|
+
#mutexes = new Map();
|
|
74
|
+
|
|
73
75
|
constructor() {
|
|
74
|
-
this._mutexes = {};
|
|
75
76
|
watt.wrapAll(this, 'lock');
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
if (!this.
|
|
79
|
+
#cleanupMutex(key) {
|
|
80
|
+
if (!this.#mutexes.has(key) || this.#mutexes.get(key).isLocked) {
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
this.#mutexes.delete(key);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
*lock(key, next) {
|
|
86
|
-
if (this.
|
|
87
|
-
|
|
88
|
-
return;
|
|
87
|
+
if (!this.#mutexes.has(key)) {
|
|
88
|
+
this.#mutexes.set(key, locks.createMutex());
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
this._mutexes[key] = locks.createMutex();
|
|
92
|
-
yield this._mutexes[key].lock(next.arg(0));
|
|
90
|
+
yield this.#mutexes.get(key).lock(next.arg(0));
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
unlock(key) {
|
|
96
|
-
this.
|
|
97
|
-
this
|
|
94
|
+
this.#mutexes.get(key)?.unlock();
|
|
95
|
+
this.#cleanupMutex(key);
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
|