优化界面布局
This commit is contained in:
30
server.js
30
server.js
@@ -495,16 +495,30 @@ const clearDownloadCache = () => {
|
||||
if (!fs.existsSync(tmpDir)) return;
|
||||
const files = fs.readdirSync(tmpDir);
|
||||
for (const file of files) {
|
||||
if (file.startsWith('s3-input-') && file.endsWith('.tmp')) {
|
||||
if (file.startsWith('s3-input-') && (file.endsWith('.tmp') || file.endsWith('.downloading'))) {
|
||||
const filePath = path.join(tmpDir, file);
|
||||
fs.rmSync(filePath, { force: true });
|
||||
} else if (file.startsWith('hls-')) {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to clear download cache:', err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
const clearTranscodeCache = () => {
|
||||
const tmpDir = CACHE_DIR;
|
||||
try {
|
||||
if (!fs.existsSync(tmpDir)) return;
|
||||
const files = fs.readdirSync(tmpDir);
|
||||
for (const file of files) {
|
||||
if (file.startsWith('hls-')) {
|
||||
const filePath = path.join(tmpDir, file);
|
||||
fs.rmSync(filePath, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to clear download cache:', err);
|
||||
console.error('Failed to clear transcode cache:', err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
@@ -618,6 +632,16 @@ app.post('/api/clear-download-cache', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/clear-transcode-cache', (req, res) => {
|
||||
try {
|
||||
clearTranscodeCache();
|
||||
res.json({ message: 'Transcode cache cleared' });
|
||||
} catch (error) {
|
||||
console.error('Error clearing transcode cache:', error);
|
||||
res.status(500).json({ error: 'Failed to clear transcode cache', detail: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/stop-transcode', (req, res) => {
|
||||
try {
|
||||
const { key } = req.body;
|
||||
|
||||
Reference in New Issue
Block a user