@social-mail/social-mail-web-server 1.4.744 → 1.4.746
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/SnapshotService.d.ts.map +1 -1
- package/dist/server/services/files/SnapshotService.js +25 -24
- package/dist/server/services/files/SnapshotService.js.map +1 -1
- package/dist/server/workflows/repair/counts/RepairEmailCountsWorkflow.d.ts.map +1 -1
- package/dist/server/workflows/repair/counts/RepairEmailCountsWorkflow.js +1 -0
- package/dist/server/workflows/repair/counts/RepairEmailCountsWorkflow.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/server/services/files/SnapshotService.ts +32 -28
- package/src/server/workflows/repair/counts/RepairEmailCountsWorkflow.ts +1 -0
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import { join } from "path";
|
|
|
11
11
|
import { cacheFor } from "../../../common/cacheFor.js";
|
|
12
12
|
import { globalEnv } from "../../../common/globalEnv.js";
|
|
13
13
|
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
14
|
+
import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
|
|
14
15
|
|
|
15
16
|
let cdn = globalEnv.cdn || "";
|
|
16
17
|
if (cdn) {
|
|
@@ -66,9 +67,24 @@ export default class SnapshotService {
|
|
|
66
67
|
async createSnapshot(folderID, sessionUser = null as SessionUser) {
|
|
67
68
|
const { db } = this;
|
|
68
69
|
db.verifyFilters = false;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
|
|
71
|
+
const sourcePath = folderID + "/%";
|
|
72
|
+
|
|
73
|
+
this.allFiles = await db.appFiles.where({ sourcePath}, (p) => (x) => Sql.text.like(x.path, p.sourcePath)
|
|
74
|
+
&& x.isDeleted === false
|
|
75
|
+
)
|
|
76
|
+
.toArray();
|
|
77
|
+
|
|
78
|
+
if (!this.allFiles.length) {
|
|
79
|
+
throw new EntityAccessError(`File not found under ${folderID}/`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for (const iterator of this.allFiles) {
|
|
83
|
+
this.fileMap.set(iterator.appFileID, iterator);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const folder = this.fileMap.get(folderID);
|
|
87
|
+
|
|
72
88
|
|
|
73
89
|
const dateCreated = DateTime.now;
|
|
74
90
|
const dateUpdated = dateCreated;
|
|
@@ -89,22 +105,11 @@ export default class SnapshotService {
|
|
|
89
105
|
const path = `${snapshotRoot.appFileID}/`;
|
|
90
106
|
snapshotRoot.path = path;
|
|
91
107
|
this.snapshotFiles.push(snapshotRoot);
|
|
92
|
-
await db.appFiles
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const sourcePath = folder.path + "%";
|
|
99
|
-
|
|
100
|
-
this.allFiles = await db.appFiles.where({ sourcePath}, (p) => (x) => Sql.text.like(x.path, p.sourcePath)
|
|
101
|
-
&& x.isDeleted === false
|
|
102
|
-
)
|
|
103
|
-
.toArray();
|
|
104
|
-
|
|
105
|
-
for (const iterator of this.allFiles) {
|
|
106
|
-
this.fileMap.set(iterator.appFileID, iterator);
|
|
107
|
-
}
|
|
108
|
+
await db.appFiles.statements.update({
|
|
109
|
+
path
|
|
110
|
+
}, {
|
|
111
|
+
appFileID: snapshotRoot.appFileID
|
|
112
|
+
});
|
|
108
113
|
|
|
109
114
|
this.root = folder;
|
|
110
115
|
this.snapshotRoot = snapshotRoot;
|
|
@@ -148,11 +153,10 @@ export default class SnapshotService {
|
|
|
148
153
|
|
|
149
154
|
async copyChildren(db: SocialMailContext, source: AppFile, dest: AppFile, copyMedia = true, siteRoot = "") {
|
|
150
155
|
const { dateCreated, dateUpdated } = dest;
|
|
151
|
-
const all = source.children;
|
|
152
156
|
|
|
153
157
|
dest.children ??= [];
|
|
154
158
|
|
|
155
|
-
for (const iterator of
|
|
159
|
+
for (const iterator of source.children) {
|
|
156
160
|
|
|
157
161
|
if(!copyMedia) {
|
|
158
162
|
if(/^(image|video|audio)/i.test(iterator.contentType)) {
|
|
@@ -160,7 +164,7 @@ export default class SnapshotService {
|
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
|
|
163
|
-
console.log(`Adding ${iterator.path} - ${iterator.name} in ${dest.
|
|
167
|
+
console.log(`Adding ${iterator.path} - ${iterator.name} in ${dest.path} - ${dest.name}`);
|
|
164
168
|
|
|
165
169
|
const child = await db.appFiles.statements.insert({
|
|
166
170
|
... iterator,
|
|
@@ -177,11 +181,11 @@ export default class SnapshotService {
|
|
|
177
181
|
|
|
178
182
|
const path = `${dest.path}${child.appFileID}/`;
|
|
179
183
|
child.path = path;
|
|
180
|
-
await db.appFiles
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
await db.appFiles.statements.update({
|
|
185
|
+
path
|
|
186
|
+
}, {
|
|
187
|
+
appFileID: child.appFileID
|
|
188
|
+
});
|
|
185
189
|
|
|
186
190
|
if (/text\/css/i.test(iterator.contentType) || /\.css$/i.test(iterator.name)) {
|
|
187
191
|
this.cssFiles.push({ source: iterator, dest: child, siteRoot });
|
|
@@ -193,7 +197,7 @@ export default class SnapshotService {
|
|
|
193
197
|
|
|
194
198
|
|
|
195
199
|
if (iterator.isFolder) {
|
|
196
|
-
await this.copyChildren(db, iterator, child, copyMedia);
|
|
200
|
+
await this.copyChildren(db, iterator, child, copyMedia, siteRoot + "/" + iterator.name );
|
|
197
201
|
} else {
|
|
198
202
|
this.snapshotSize += Number(iterator.fileSize);
|
|
199
203
|
}
|