mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
脚本管理和日志管理支持下载
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import path from 'path';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import winston from 'winston';
|
||||
import config from '../config';
|
||||
|
||||
@Service()
|
||||
export default class LogService {
|
||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||
|
||||
public checkFilePath(filePath: string, fileName: string) {
|
||||
const finalPath = path.resolve(config.logPath, filePath, fileName);
|
||||
return finalPath.startsWith(config.logPath) ? finalPath : '';
|
||||
}
|
||||
}
|
||||
@@ -64,10 +64,15 @@ export default class ScriptService {
|
||||
return { code: 200 };
|
||||
}
|
||||
|
||||
public async getFile(filePath: string, fileName: string) {
|
||||
public checkFilePath(filePath: string, fileName: string) {
|
||||
const finalPath = path.resolve(config.scriptPath, filePath, fileName);
|
||||
return finalPath.startsWith(config.scriptPath) ? finalPath : '';
|
||||
}
|
||||
|
||||
if (!finalPath.startsWith(config.scriptPath)) {
|
||||
public async getFile(filePath: string, fileName: string) {
|
||||
const finalPath = this.checkFilePath(filePath, fileName);
|
||||
|
||||
if (!finalPath) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user