Add page data delivery and publication guards
This commit is contained in:
+22
-5
@@ -31,7 +31,7 @@ function extractHtmlSummary(content) {
|
||||
|
||||
async function findPageByWorkspaceRelativePath(pool, userId, relativePath) {
|
||||
const [rows] = await pool.query(
|
||||
`SELECT p.id, p.updated_at
|
||||
`SELECT p.id, p.updated_at, pv.version_no
|
||||
FROM h5_page_records p
|
||||
LEFT JOIN h5_page_versions pv ON pv.id = p.current_version_id
|
||||
WHERE p.user_id = ?
|
||||
@@ -49,7 +49,11 @@ async function findPageByWorkspaceRelativePath(pool, userId, relativePath) {
|
||||
);
|
||||
const row = rows[0];
|
||||
if (!row) return null;
|
||||
return { id: row.id, updatedAt: Number(row.updated_at ?? 0) };
|
||||
return {
|
||||
id: row.id,
|
||||
updatedAt: Number(row.updated_at ?? 0),
|
||||
versionNo: Number(row.version_no ?? 0) || null,
|
||||
};
|
||||
}
|
||||
|
||||
function parseJsonColumn(value, fallback = {}) {
|
||||
@@ -64,7 +68,8 @@ function parseJsonColumn(value, fallback = {}) {
|
||||
|
||||
async function loadIndexedWorkspacePages(pool, userId) {
|
||||
const [rows] = await pool.query(
|
||||
`SELECT p.id, p.updated_at, p.source_asset_id, p.workspace_relative_path, pv.source_snapshot_json
|
||||
`SELECT p.id, p.updated_at, p.source_asset_id, p.workspace_relative_path,
|
||||
pv.version_no, pv.source_snapshot_json
|
||||
FROM h5_page_records p
|
||||
LEFT JOIN h5_page_versions pv ON pv.id = p.current_version_id
|
||||
WHERE p.user_id = ? AND p.status <> 'deleted'`,
|
||||
@@ -80,10 +85,15 @@ async function loadIndexedWorkspacePages(pool, userId) {
|
||||
byPath.set(relativePath, {
|
||||
id: row.id,
|
||||
updatedAt: Number(row.updated_at ?? 0),
|
||||
versionNo: Number(row.version_no ?? 0) || null,
|
||||
});
|
||||
}
|
||||
if (row.source_asset_id && relativePath) {
|
||||
byPath.set(`asset:${row.source_asset_id}`, { id: row.id, updatedAt: Number(row.updated_at ?? 0) });
|
||||
byPath.set(`asset:${row.source_asset_id}`, {
|
||||
id: row.id,
|
||||
updatedAt: Number(row.updated_at ?? 0),
|
||||
versionNo: Number(row.version_no ?? 0) || null,
|
||||
});
|
||||
}
|
||||
}
|
||||
return byPath;
|
||||
@@ -169,9 +179,16 @@ async function upsertWorkspaceHtmlPage({
|
||||
}
|
||||
await pageService.updatePage(userId, existing.id, {
|
||||
...pageInput,
|
||||
expectedVersion: existing.versionNo ?? undefined,
|
||||
changeNote: '同步工作区页面更新',
|
||||
}, {
|
||||
snapshot,
|
||||
});
|
||||
indexedPages.set(relativePath, {
|
||||
id: existing.id,
|
||||
updatedAt: Date.now(),
|
||||
versionNo: existing.versionNo != null ? existing.versionNo + 1 : null,
|
||||
});
|
||||
indexedPages.set(relativePath, { id: existing.id, updatedAt: Date.now() });
|
||||
return 'updated';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user