@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/dist/server/services/files/FileVersionService.d.ts.map +1 -1
- package/dist/server/services/files/FileVersionService.js +31 -90
- package/dist/server/services/files/FileVersionService.js.map +1 -1
- package/dist/server/services/files/SnapshotService.d.ts.map +1 -1
- package/dist/server/services/files/SnapshotService.js +2 -1
- package/dist/server/services/files/SnapshotService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/server/services/files/FileVersionService.ts +27 -30
- package/src/server/services/files/SnapshotService.ts +2 -1
package/package.json
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
|
-
import {
|
|
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
|
-
@
|
|
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
|
-
|
|
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.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
}
|