@travetto/model-file 5.0.14 → 5.0.15
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 +7 -7
- package/src/service.ts +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-file",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.15",
|
|
4
4
|
"description": "File system backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datastore",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"directory": "module/model-file"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@travetto/config": "^5.0.
|
|
29
|
-
"@travetto/di": "^5.0.
|
|
30
|
-
"@travetto/model": "^5.0.
|
|
31
|
-
"@travetto/schema": "^5.0.
|
|
28
|
+
"@travetto/config": "^5.0.14",
|
|
29
|
+
"@travetto/di": "^5.0.14",
|
|
30
|
+
"@travetto/model": "^5.0.15",
|
|
31
|
+
"@travetto/schema": "^5.0.14"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@travetto/cli": "^5.0.
|
|
35
|
-
"@travetto/test": "^5.0.
|
|
34
|
+
"@travetto/cli": "^5.0.17",
|
|
35
|
+
"@travetto/test": "^5.0.16"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@travetto/cli": {
|
package/src/service.ts
CHANGED
|
@@ -215,7 +215,17 @@ export class FileModelService implements ModelCrudSupport, ModelBlobSupport, Mod
|
|
|
215
215
|
|
|
216
216
|
// Expiry
|
|
217
217
|
async deleteExpired<T extends ModelType>(cls: Class<T>): Promise<number> {
|
|
218
|
-
|
|
218
|
+
let deleted = 0;
|
|
219
|
+
for await (const [_id, file] of FileModelService.scanFolder(await this.#resolveName(cls, '.json'), '.json')) {
|
|
220
|
+
try {
|
|
221
|
+
const res = await ModelCrudUtil.load(cls, await fs.readFile(file));
|
|
222
|
+
if (ModelExpiryUtil.getExpiryState(cls, res).expired) {
|
|
223
|
+
await fs.rm(file, { force: true });
|
|
224
|
+
deleted += 1;
|
|
225
|
+
}
|
|
226
|
+
} catch { } // Don't let a single failure stop the process
|
|
227
|
+
}
|
|
228
|
+
return deleted;
|
|
219
229
|
}
|
|
220
230
|
|
|
221
231
|
// Storage management
|