core: delete related ddoc when deleting tdoc

This commit is contained in:
undefined committed 2021-08-25 05:19:33 +00:00
1 parent c78fc82d5b
commit 4c6aeeb914
6 files changed
+26 -11

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.33.6", "version": "2.33.7",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+1
View File
@@ -458,6 +458,7 @@ export async function del(domainId: string, tid: ObjectID, type: Type = document
await Promise.all([ await Promise.all([
document.deleteOne(domainId, type, tid), document.deleteOne(domainId, type, tid),
document.deleteMultiStatus(domainId, type, { docId: tid }), document.deleteMultiStatus(domainId, type, { docId: tid }),
document.deleteMulti(domainId, document.TYPE_DISCUSSION, { parentType: type, parentId: tid }),
]); ]);
} }
+12
View File
@@ -458,6 +458,18 @@ const scripts: UpgradeScript[] = [
); );
return true; return true;
}, },
async function _41_42() {
const _FRESH_INSTALL_IGNORE = 1;
await iterateAllDomain(async (ddoc) => {
const cursor = discussion.getMulti(ddoc._id, { parentType: document.TYPE_CONTEST });
while (await cursor.hasNext()) {
const doc = await cursor.next();
const tdoc = await document.coll.findOne({ docType: doc.parentType, docId: doc.parentId });
if (!tdoc) await discussion.del(ddoc._id, doc.docId);
}
});
return true;
},
]; ];
export default scripts; export default scripts;
+10 -8
View File
@@ -172,14 +172,16 @@ const getHash = (i) => {
const getUrl = (files) => files.map((i) => `/${i}?${getHash(i)}`); const getUrl = (files) => files.map((i) => `/${i}?${getHash(i)}`);
bus.on('app/started', () => { bus.on('app/started', () => {
const files = readdirSync(join(tmpdir(), 'hydro', 'public')); setTimeout(() => {
const pages = files.filter((file) => file.endsWith('.page.js')); const files = readdirSync(join(tmpdir(), 'hydro', 'public'));
const themes = files.filter((file) => file.endsWith('.theme.js')); const pages = files.filter((file) => file.endsWith('.page.js'));
UiContextBase.extraPages = getUrl(pages); const themes = files.filter((file) => file.endsWith('.theme.js'));
UiContextBase.themes = {}; UiContextBase.extraPages = getUrl(pages);
for (const theme of themes) { UiContextBase.themes = {};
UiContextBase.themes[theme] = `/${theme}?${getHash(theme)}`; for (const theme of themes) {
} UiContextBase.themes[theme] = `/${theme}?${getHash(theme)}`;
}
}, 1000);
}); });
global.Hydro.handler.ui = async () => { global.Hydro.handler.ui = async () => {
+1 -1
View File
@@ -311,7 +311,7 @@ h1, h2, h3, h4, h5, h6
list-style: decimal list-style: decimal
margin-left: 1.9em margin-left: 1.9em
.typo li ul, .typo li ol .typo li ol
margin-top: 1.2em margin-top: 1.2em
margin-bottom: 1.2em margin-bottom: 1.2em
margin-left: 2em margin-left: 2em
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.18.2", "version": "4.18.3",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",