CH-J Server ManagerSSH를 통한 서버 관리
메뉴
공개된 소스

CH-J Server Manager

특정 애플리케이션 릴리스의 디렉터리와 파일을 살펴보세요.

소스 ZIP 다운로드
CH-J / Server Manager 377 개 파일
core-20261019T111616Z-160a00bfcddc 추가됨: · 빌드됨:
downloadCache.js 추가됨: 날짜 기록 없음 1.9 KB · 51 줄
코드 파일 다운로드
1"use strict";
3const fs = require("node:fs");
4const path = require("node:path");
6function resolvedCacheRoot(rootDir) {
7 const raw = String(rootDir || "").trim();
8 if (!raw) throw new Error("Download cache root is required.");
9 const resolved = path.resolve(raw);
10 if (resolved === path.parse(resolved).root) throw new Error("Refusing to use a filesystem root as a download cache.");
11 return resolved;
14function cleanDownloadCache(rootDir) {
15 const root = resolvedCacheRoot(rootDir);
16 const existed = fs.existsSync(root);
17 fs.rmSync(root, { recursive: true, force: true });
18 fs.mkdirSync(root, { recursive: true, mode: 0o700 });
19 return { cleaned: existed, root };
22function removeCachedFile(rootDir, filePath) {
23 const root = resolvedCacheRoot(rootDir);
24 const target = path.resolve(String(filePath || ""));
25 const relative = path.relative(root, target);
26 if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) {
27 throw new Error("Downloaded package path is outside its cache.");
28 }
29 if (!fs.existsSync(target)) return { removed: false, path: target };
30 if (!fs.lstatSync(target).isFile()) throw new Error("Downloaded package is not a regular file.");
31 const realRoot = fs.realpathSync(root);
32 const realTarget = fs.realpathSync(target);
33 const realRelative = path.relative(realRoot, realTarget);
34 if (!realRelative || realRelative.startsWith("..") || path.isAbsolute(realRelative)) {
35 throw new Error("Downloaded package resolves outside its cache.");
36 }
37 fs.unlinkSync(target);
39 let current = path.dirname(target);
40 while (current !== root) {
41 try { fs.rmdirSync(current); }
42 catch (error) {
43 if (error?.code === "ENOTEMPTY" || error?.code === "EEXIST" || error?.code === "ENOENT") break;
44 throw error;
45 }
46 current = path.dirname(current);
47 }
48 return { removed: true, path: target };
51module.exports = { cleanDownloadCache, removeCachedFile, resolvedCacheRoot };
SHA-256a8d7b86d725cd6d52e5937995e869b1cedadde09458c52442b2eb91009aaccb8

CH-J Proprietary Software License 1.14 · 소스는 CH-J Proprietary Software License 1.14에 따라 제공됩니다. 소스를 공개한다고 해서 라이선스 조항이 바뀌거나 추가 권리가 부여되지는 않습니다.

압축 파일 SHA-256a9605c0870a223b6a8542bb0705edd51d8b04f3069582653417a8397fabcc09a
파일