@social-mail/social-mail-web-server 1.4.749 → 1.4.751

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.749",
3
+ "version": "1.4.751",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3,7 +3,7 @@ import semver from "semver";
3
3
 
4
4
  export default async function seedUI(config: DBConfig) {
5
5
 
6
- const version = "1.2.291";
6
+ const version = "1.2.292";
7
7
 
8
8
  const existing = await config.get(UIPackageConfig, false);
9
9
  if (existing) {
@@ -68,6 +68,8 @@ export default class SnapshotService {
68
68
  const { db } = this;
69
69
  db.verifyFilters = false;
70
70
 
71
+ await using tx = await db.connection.createTransaction();
72
+
71
73
  const sourcePath = folderID + "/%";
72
74
 
73
75
  this.allFiles = await db.appFiles.where({ sourcePath}, (p) => (x) => Sql.text.like(x.path, p.sourcePath)
@@ -125,7 +127,7 @@ export default class SnapshotService {
125
127
 
126
128
  if (html) {
127
129
  const htmlFile = await this.tempFileService.createFrom(source.name, Buffer.from(html, "utf8"), "text/html");
128
- await this.storage.saveFile(htmlFile, dest);
130
+ await this.storage.updateFile(dest, htmlFile);
129
131
  }
130
132
  }
131
133
 
@@ -138,15 +140,19 @@ export default class SnapshotService {
138
140
 
139
141
  if (html) {
140
142
  const htmlFile = await this.tempFileService.createFrom(source.name, Buffer.from(html, "utf8"), "text/html");
141
- await this.storage.saveFile(htmlFile, dest);
143
+ await this.storage.updateFile(dest, htmlFile);
142
144
  }
143
145
  }
144
146
 
147
+ await db.saveChanges();
148
+
145
149
  await this.db.appFiles.where(this.snapshotRoot, (p) => (x) => x.appFileID === p.appFileID)
146
150
  .update({ size: this.snapshotSize}, (p) => (x) => ({
147
151
  fileSize: Sql.cast.asBigInt(p.size)
148
152
  }));
149
153
 
154
+ await tx.commit();
155
+
150
156
  return snapshotRoot;
151
157
 
152
158
  }
@@ -164,7 +170,7 @@ export default class SnapshotService {
164
170
  }
165
171
  }
166
172
 
167
- console.log(`Adding ${srcChild.path} - ${srcChild.name} in ${dest.path} - ${dest.name}`);
173
+ // console.log(`Adding ${srcChild.path} - ${srcChild.name} in ${dest.path} - ${dest.name}`);
168
174
 
169
175
  const destChild = await db.appFiles.statements.insert({
170
176
  ... srcChild,
@@ -155,6 +155,11 @@ export default abstract class BaseStorage {
155
155
  // return cachedPath;
156
156
  }
157
157
 
158
+ async updateFile(appFile: AppFile, file: LocalFile) {
159
+ const fc = await this.saveFileContent(file, void 0, FileType.canBeCompressed(file));
160
+ appFile.fileContentID = fc.fileContentID;
161
+ }
162
+
158
163
  async saveFile(file: LocalFile, extra?: Partial<AppFile>) {
159
164
 
160
165
  const scope = globalServices.createScope();
@@ -170,7 +175,7 @@ export default abstract class BaseStorage {
170
175
 
171
176
  let appFile: AppFile;
172
177
 
173
- if (parentID) {
178
+ if (parentID && name) {
174
179
  appFile = await db.appFiles
175
180
  .where({ parentID, name }, (p) =>
176
181
  (x) => x.parentID === p.parentID