mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
add hydrojudge cache clearCompileCache
This commit is contained in:
2 files changed
+33
-2
No files matched your search
+3
-1
@@ -397,7 +397,9 @@ ${nixConfBase}`);
|
|||||||
exec('nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs', { stdio: 'inherit' });
|
exec('nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs', { stdio: 'inherit' });
|
||||||
exec('nix-channel --update', { stdio: 'inherit' });
|
exec('nix-channel --update', { stdio: 'inherit' });
|
||||||
},
|
},
|
||||||
`nix-env -iA ${['pm2', 'yarn', 'esbuild', 'bash', 'unzip', 'zip', 'diffutils', 'patch', 'screen'].map((i) => `nixpkgs.${i}`).join(' ')}`,
|
`nix-env -iA ${[
|
||||||
|
'pm2', 'yarn', 'esbuild', 'bash', 'unzip', 'zip', 'diffutils', 'patch', 'screen', 'gawk',
|
||||||
|
].map((i) => `nixpkgs.${i}`).join(' ')}`,
|
||||||
'yarn config set disable-self-update-check true',
|
'yarn config set disable-self-update-check true',
|
||||||
async () => {
|
async () => {
|
||||||
const rl = createInterface(process.stdin, process.stdout);
|
const rl = createInterface(process.stdin, process.stdout);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export = async function main() {
|
|||||||
fs.emptyDirSync(CACHE_DIR);
|
fs.emptyDirSync(CACHE_DIR);
|
||||||
logger.info('Cleaned cache.');
|
logger.info('Cleaned cache.');
|
||||||
} else if (argv.args[1] === 'prune') {
|
} else if (argv.args[1] === 'prune') {
|
||||||
const duration = +argv.options.duration || 30;
|
const duration = +argv.options.duration || +argv.options.days || 30;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const hosts = await fs.readdir(CACHE_DIR, { withFileTypes: true });
|
const hosts = await fs.readdir(CACHE_DIR, { withFileTypes: true });
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
@@ -59,5 +59,34 @@ export = async function main() {
|
|||||||
for (const [domain, s] of top10) {
|
for (const [domain, s] of top10) {
|
||||||
logger.info(' %s: %s', domain, size(s));
|
logger.info(' %s: %s', domain, size(s));
|
||||||
}
|
}
|
||||||
|
} else if (argv.args[1] === 'clearCompileCache') {
|
||||||
|
const hosts = await fs.readdir(CACHE_DIR, { withFileTypes: true });
|
||||||
|
let cnt = 0;
|
||||||
|
for (const host of hosts) {
|
||||||
|
const hostdir = path.resolve(CACHE_DIR, host.name);
|
||||||
|
if (!host.isDirectory()) continue;
|
||||||
|
const domains = await fs.readdir(hostdir, { withFileTypes: true });
|
||||||
|
for (const domain of domains) {
|
||||||
|
if (!domain.isDirectory()) continue;
|
||||||
|
const domaindir = path.resolve(hostdir, domain.name);
|
||||||
|
const problems = await fs.readdir(domaindir, { withFileTypes: true });
|
||||||
|
for (const problem of problems) {
|
||||||
|
const problemdir = path.resolve(domaindir, problem.name);
|
||||||
|
if (!fs.statSync(problemdir).isDirectory()) continue;
|
||||||
|
const etags = path.resolve(problemdir, 'etags');
|
||||||
|
if (fs.existsSync(etags)) {
|
||||||
|
const etag = JSON.parse(await fs.readFile(etags, 'utf-8'));
|
||||||
|
if (etag['*cache']) {
|
||||||
|
const removed = etag['*cache'];
|
||||||
|
delete etag['*cache'];
|
||||||
|
await fs.writeFile(etags, JSON.stringify(etag));
|
||||||
|
logger.info('Removed bianry %s %o', problemdir, removed);
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info('Done! %d items deleted.', cnt);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user