@social-mail/social-mail-web-server 1.7.769 → 1.7.770

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.7.769",
3
+ "version": "1.7.770",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,19 +25,22 @@ export default class BaseDiskCache {
25
25
  protected readonly minSize: number;
26
26
  protected readonly updateAccessTime: boolean;
27
27
  protected readonly maxAge: number;
28
+ protected readonly minAge: number;
28
29
  constructor(
29
30
  {
30
31
  root,
31
32
  keepTTLSeconds = 3600,
32
33
  minSize = Number.MAX_SAFE_INTEGER,
33
34
  updateAccessTime = true,
34
- maxAge = 1
35
+ maxAge = 1,
36
+ minAge = 1
35
37
  }: {
36
38
  root: string;
37
39
  keepTTLSeconds?: number;
38
40
  minSize?: number;
39
41
  updateAccessTime?: boolean;
40
42
  maxAge?: number;
43
+ minAge?: number;
41
44
  }
42
45
  ) {
43
46
  this.root = root;
@@ -45,6 +48,7 @@ export default class BaseDiskCache {
45
48
  this.minSize = minSize;
46
49
  this.updateAccessTime = updateAccessTime;
47
50
  this.maxAge = maxAge;
51
+ this.minAge = minAge;
48
52
  ensureDir(root);
49
53
  // eslint-disable-next-line no-console
50
54
  setTimeout(() => this.clean().catch(console.error), 1000);
@@ -206,7 +210,9 @@ export default class BaseDiskCache {
206
210
 
207
211
  let total = 0;
208
212
 
209
- for(let i=this.maxAge;i>0;i--) {
213
+ const min = this.minAge;
214
+
215
+ for(let i=this.maxAge;i>= min;i--) {
210
216
  const s = await fsp.statfs(this.root);
211
217
  const freeSize = s.bavail * s.bsize;
212
218
 
@@ -8,5 +8,6 @@ const tmpdir = path.join(globalEnv.tmpDir, "t");
8
8
  export const tempDiskCache = new BaseDiskCache({
9
9
  root: tmpdir,
10
10
  keepTTLSeconds: 4 * 60 * 60,
11
- maxAge: 7
11
+ maxAge: 7,
12
+ minAge: 0
12
13
  });