create zip
This commit is contained in:
parent
c75ff5a02e
commit
1241481405
|
|
@ -4,6 +4,7 @@ import fs from "fs";
|
|||
import path from "path";
|
||||
import { gzipAsync } from "../ws/sync/entity/zlib";
|
||||
import { validate } from "uuid";
|
||||
import { dir } from "dir";
|
||||
|
||||
export const _ = {
|
||||
url: "/prod-zip/:site_id",
|
||||
|
|
@ -30,6 +31,7 @@ export const _ = {
|
|||
code.path(site_id, "server", "build")
|
||||
),
|
||||
site: readDirectoryRecursively(code.path(site_id, "site", "build")),
|
||||
core: readDirectoryRecursively(dir.data(`prod`)),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { gzipAsync } from "../../sync/entity/zlib";
|
||||
import { eg } from "../edit-global";
|
||||
const history = {} as Record<string, string>;
|
||||
|
||||
export const diffLocal = (ws: any, msg: any) => {
|
||||
return new Promise<void>((resolve) => {
|
||||
|
|
@ -31,6 +33,37 @@ export const diffLocal = (ws: any, msg: any) => {
|
|||
if (msg.id) {
|
||||
const page = eg.edit.page[msg.id].doc.getMap("map").toJSON();
|
||||
try {
|
||||
const id = msg.id;
|
||||
let mode = "create" as "create" | "update";
|
||||
const cur = Math.round(Date.now() / 5000) + "";
|
||||
if (history[id] && history[id] === cur) {
|
||||
mode = "update";
|
||||
}
|
||||
history[id] = cur;
|
||||
if (mode === "create") {
|
||||
await _db.page_history.create({
|
||||
data: {
|
||||
id_page: id,
|
||||
content_tree: await gzipAsync(
|
||||
JSON.stringify(page.content_tree)
|
||||
),
|
||||
ts: history[id],
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await _db.page_history.updateMany({
|
||||
data: {
|
||||
content_tree: await gzipAsync(
|
||||
JSON.stringify(page.content_tree)
|
||||
),
|
||||
},
|
||||
where: {
|
||||
id_page: id,
|
||||
ts: history[id],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await _db.page.update({
|
||||
where: { id: page.id },
|
||||
data: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue