mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
黑名单功能
This commit is contained in:
1 parent
55912b087d
commit
160b4482cc
11 files changed
+282
-158
No files matched your search
+6
-12
@@ -3,9 +3,7 @@
|
||||
/* eslint-disable no-eval */
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const zlib = require('zlib');
|
||||
const path = require('path');
|
||||
const yaml = require('js-yaml');
|
||||
const download = require('./download');
|
||||
|
||||
function root(name) {
|
||||
@@ -28,18 +26,14 @@ for (const i of moduleRoots) {
|
||||
|
||||
async function getInstalled() {
|
||||
const modules = [];
|
||||
const files = fs.readdirSync(moduleRoot);
|
||||
const files = fs.readdirSync(`${os.tmpdir()}/hydro/tmp`);
|
||||
for (const file of files) {
|
||||
if (file.endsWith('.hydro')) {
|
||||
const info = `${os.tmpdir()}/hydro/tmp/${file}/hydro.json`;
|
||||
if (fs.existsSync(info)) {
|
||||
try {
|
||||
const f = fs.readFileSync(root(`${moduleRoot}/${file}`));
|
||||
const s = fs.statSync(root(`${moduleRoot}/${file}`));
|
||||
const m = {
|
||||
...yaml.safeLoad(zlib.gunzipSync(f)),
|
||||
filename: file.split('.')[0],
|
||||
size: s.size,
|
||||
};
|
||||
modules.push(m);
|
||||
const m = file;
|
||||
const t = JSON.parse(fs.readFileSync(info).toString());
|
||||
modules.push(`${m}|${t.id}`);
|
||||
} catch (e) {
|
||||
if (e.code === 'Z_DATA_ERROR') {
|
||||
console.error(`Module Load Fail: ${file} (File Corrupted)`);
|
||||
|
||||
Reference in new issue
Block a user