mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-25 06:14:06 +00:00
fix doc images (#1083)
* perf: clear tmp files * fix doc images * update docker-compose
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { isProduction } from '../system/constants';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export const removeFilesByPaths = (paths: string[]) => {
|
||||
paths.forEach((path) => {
|
||||
@@ -42,3 +44,30 @@ export const clearDirFiles = (dirPath: string) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const clearTmpUploadFiles = () => {
|
||||
if (!isProduction) return;
|
||||
const tmpPath = '/tmp';
|
||||
|
||||
fs.readdir(tmpPath, (err, files) => {
|
||||
if (err) return;
|
||||
|
||||
for (const file of files) {
|
||||
if (file === 'v8-compile-cache-0') continue;
|
||||
|
||||
const filePath = path.join(tmpPath, file);
|
||||
|
||||
fs.stat(filePath, (err, stats) => {
|
||||
if (err) return;
|
||||
|
||||
// 如果文件是在1小时前上传的,则认为是临时文件并删除它
|
||||
if (Date.now() - stats.mtime.getTime() > 1 * 60 * 60 * 1000) {
|
||||
fs.unlink(filePath, (err) => {
|
||||
if (err) return;
|
||||
console.log(`Deleted temp file: ${filePath}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@@ -1 +1,3 @@
|
||||
export const FastGPTProUrl = process.env.PRO_URL ? `${process.env.PRO_URL}/api` : '';
|
||||
|
||||
export const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
Reference in New Issue
Block a user