@travetto/model 3.1.3 → 3.1.4
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/provider/file.ts +7 -3
- package/src/provider/memory.ts +5 -1
package/package.json
CHANGED
package/src/provider/file.ts
CHANGED
|
@@ -211,13 +211,17 @@ export class FileModelService implements ModelCrudSupport, ModelStreamSupport, M
|
|
|
211
211
|
|
|
212
212
|
// Expiry
|
|
213
213
|
async deleteExpired<T extends ModelType>(cls: Class<T>): Promise<number> {
|
|
214
|
-
const
|
|
214
|
+
const deleting = [];
|
|
215
215
|
for await (const el of this.list(cls)) {
|
|
216
216
|
if (ModelExpiryUtil.getExpiryState(cls, el).expired) {
|
|
217
|
-
|
|
217
|
+
deleting.push(this.delete(cls, el.id).catch(err => {
|
|
218
|
+
if (!(err instanceof NotFoundError)) {
|
|
219
|
+
throw err;
|
|
220
|
+
}
|
|
221
|
+
}));
|
|
218
222
|
}
|
|
219
223
|
}
|
|
220
|
-
return (await Promise.all(
|
|
224
|
+
return (await Promise.all(deleting)).length;
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
// Storage management
|
package/src/provider/memory.ts
CHANGED
|
@@ -272,7 +272,11 @@ export class MemoryModelService implements ModelCrudSupport, ModelStreamSupport,
|
|
|
272
272
|
const store = this.#getStore(cls);
|
|
273
273
|
for (const id of [...store.keys()]) {
|
|
274
274
|
if ((ModelExpiryUtil.getExpiryState(cls, await this.get(cls, id))).expired) {
|
|
275
|
-
deleting.push(this.delete(cls, id)
|
|
275
|
+
deleting.push(this.delete(cls, id).catch(err => {
|
|
276
|
+
if (!(err instanceof NotFoundError)) {
|
|
277
|
+
throw err;
|
|
278
|
+
}
|
|
279
|
+
}));
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
282
|
return (await Promise.all(deleting)).length;
|