@social-mail/social-mail-web-server 1.4.682 → 1.4.684

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.4.682",
3
+ "version": "1.4.684",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,49 +1,46 @@
1
- import { RegisterSingleton } from "@entity-access/entity-access/dist/di/di.js";
1
+ import { RegisterScoped, ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
2
2
  import AppFile from "../../model/entities/AppFile.js";
3
3
  import { globalServices } from "../../../globalServices.js";
4
4
  import SocialMailContext from "../../model/SocialMailContext.js";
5
5
  import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
6
6
  import { SessionUser } from "@entity-access/server-pages/dist/core/SessionUser.js";
7
7
 
8
- @RegisterSingleton
8
+ @RegisterScoped
9
9
  export default class FileVersionService {
10
10
 
11
11
  public async saveVersion(user: SessionUser, file: AppFile) {
12
12
  const { userID, sessionID } = user ?? {};
13
- using scope = globalServices.createScope();
14
- const db = scope.resolve(SocialMailContext);
13
+ const db = ServiceProvider.resolve(this, SocialMailContext);
15
14
  const dateCreated = DateTime.now;
16
15
  db.verifyFilters = false;
17
16
  db.raiseEvents = false;
18
- await db.connection.runInTransaction(async () => {
19
- await db.fileVersions.saveDirect({
20
- mode: "insert",
21
- changes: {
22
- fileID: file.appFileID,
23
- userID,
24
- sessionID,
25
- fileContentID: file.fileContentID,
26
- name: file.name,
27
- dateCreated
28
- }
29
- });
30
- await db.appFiles.where(file, (p) => (x) => x.appFileID === p.appFileID)
31
- .update(void 0, (p) => (x) => ({ versions: x.versions === null ? 0 : x.versions + 1 }));
17
+ await db.fileVersions.saveDirect({
18
+ mode: "insert",
19
+ changes: {
20
+ fileID: file.appFileID,
21
+ userID,
22
+ sessionID,
23
+ fileContentID: file.fileContentID,
24
+ name: file.name,
25
+ dateCreated
26
+ }
27
+ });
28
+ await db.appFiles.where(file, (p) => (x) => x.appFileID === p.appFileID)
29
+ .update(void 0, (p) => (x) => ({ versions: x.versions === null ? 0 : x.versions + 1 }));
32
30
 
33
- if (!file.path && file.parentID) {
34
- // get from parent...
35
- file = await db.appFiles
36
- .where(file, (p) => (x) => x.appFileID === p.parentID)
37
- .first();
38
- if (!file?.path) {
39
- return;
40
- }
31
+ if (!file.path && file.parentID) {
32
+ // get from parent...
33
+ file = await db.appFiles
34
+ .where(file, (p) => (x) => x.appFileID === p.parentID)
35
+ .first();
36
+ if (!file?.path) {
37
+ return;
41
38
  }
39
+ }
42
40
 
43
- const rootFolder = /\d+/.exec(file.path)[0] as any;
44
- await db.websiteFolders.where({ rootFolder }, (p) => (x) => x.folderID === p.rootFolder)
45
- .update(void 0, (p) => (x) => ({ isModified: true }));
46
- });
41
+ const rootFolder = /\d+/.exec(file.path)[0] as any;
42
+ await db.websiteFolders.where({ rootFolder }, (p) => (x) => x.folderID === p.rootFolder)
43
+ .update(void 0, (p) => (x) => ({ isModified: true }));
47
44
  }
48
45
 
49
46
  }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import Inject, { RegisterScoped, RegisterTransient } from "@entity-access/entity-access/dist/di/di.js";
2
3
  import { JSDOM } from 'jsdom';
3
4
  import SocialMailContext from "../../model/SocialMailContext.js";
@@ -189,7 +190,7 @@ export default class SnapshotService {
189
190
  if (iterator.isFolder) {
190
191
  await this.copyChildren(db, iterator, child, path, copyMedia, siteRoot + "/" + child.name);
191
192
  } else {
192
- this.snapshotSize += iterator.fileSize;
193
+ this.snapshotSize += Number(iterator.fileSize);
193
194
  }
194
195
  }
195
196
  }