@less-is-more/less-js 1.5.0-6 → 1.5.0-8
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/src/nas.js +15 -10
package/package.json
CHANGED
package/src/nas.js
CHANGED
|
@@ -89,7 +89,13 @@ class Nas {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// 读取缓存文件
|
|
92
|
-
|
|
92
|
+
let content;
|
|
93
|
+
try {
|
|
94
|
+
content = fs.readFileSync(filePath, "utf8");
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.warn("读取缓存文件失败:", filePath, e);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
93
99
|
const lines = content.split("\n");
|
|
94
100
|
|
|
95
101
|
if (lines.length >= 2) {
|
|
@@ -184,24 +190,23 @@ class Nas {
|
|
|
184
190
|
try {
|
|
185
191
|
const content = fs.readFileSync(filePath, "utf8");
|
|
186
192
|
const lines = content.split("\n");
|
|
187
|
-
|
|
193
|
+
|
|
188
194
|
if (lines.length >= 1) {
|
|
189
195
|
const expireTimeString = lines[0];
|
|
190
196
|
const expireTime = parseInt(expireTimeString);
|
|
191
|
-
|
|
192
|
-
if (
|
|
197
|
+
|
|
198
|
+
if (
|
|
199
|
+
!isNaN(expireTime) &&
|
|
200
|
+
expireTime !== -1 &&
|
|
201
|
+
Date.now() > expireTime
|
|
202
|
+
) {
|
|
203
|
+
console.log("删除过期缓存文件:", filePath);
|
|
193
204
|
// 文件已过期,删除文件
|
|
194
205
|
fs.unlinkSync(filePath);
|
|
195
206
|
}
|
|
196
207
|
}
|
|
197
208
|
} catch (e) {
|
|
198
209
|
console.warn("检查缓存文件过期时间失败:", filePath, e);
|
|
199
|
-
// 如果检查失败,尝试直接删除文件
|
|
200
|
-
try {
|
|
201
|
-
fs.unlinkSync(filePath);
|
|
202
|
-
} catch (deleteError) {
|
|
203
|
-
console.warn("删除缓存文件失败:", filePath, deleteError);
|
|
204
|
-
}
|
|
205
210
|
}
|
|
206
211
|
}
|
|
207
212
|
}
|