返回提交历史
Modified
src/index.ts
+13
-1
XFEstudio/SpaceNinjaServer
chore: check that mongo executable size is as expected (#4215)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4215 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
c8818a84
代码差异
1 个文件
+13
-1
@@ -39,9 +39,21 @@ let mongodUri = config.database;
39
39
if (typeof mongodUri != "string") {
40
40
const dataDir = path.resolve(mongodUri.dbPath);
41
41
fs.mkdirSync(dataDir, { recursive: true });
42
43
const downloadDir = "node_modules/.cache";
44
45
// Breaking MongoMemoryServer is as easy as pressing Ctrl+C while it's extracting and it has no "cache integrity checking" of its own (https://github.com/typegoose/mongodb-memory-server/issues/991)
46
if (fs.existsSync(`${downloadDir}/mongod-x64-win32-7.0.34.exe`)) {
47
if (fs.statSync(`${downloadDir}/mongod-x64-win32-7.0.34.exe`).size != 65191936) {
48
logger.debug(`${downloadDir}/mongod-x64-win32-7.0.34.exe has invalid size, deleting it`);
49
fs.unlinkSync(`${downloadDir}/mongod-x64-win32-7.0.34.exe`);
50
}
51
}
52
42
53
const mongod = await MongoMemoryServer.create({
43
54
binary: {
44
version: mongodUri.engine == "MongoDB 8.0" ? undefined : "7.0.34" // Check https://www.mongodb.com/docs/v7.0/release-notes/7.0/ for updates :)
55
version: mongodUri.engine == "MongoDB 8.0" ? undefined : "7.0.34", // Check https://www.mongodb.com/docs/v7.0/release-notes/7.0/ for updates :)
56
downloadDir
45
57
},
46
58
instance: {
47
59
dbPath: dataDir,