优化布局
This commit is contained in:
24
server.js
24
server.js
@@ -566,9 +566,11 @@ app.get('/api/videos', async (req, res) => {
|
||||
const safeBucket = bucket.replace(/[^a-z0-9]/gi, '_');
|
||||
const safeKeySegments = key.split('/').map(segment => segment.replace(/[^a-z0-9]/gi, '_'));
|
||||
const hlsDir = path.join(CACHE_DIR, `hls-${safeBucket}-${safeKeySegments.join('-')}`);
|
||||
const tmpInputPath = path.join(CACHE_DIR, `s3-input-${safeBucket}-${safeKeySegments.join('-')}.tmp`);
|
||||
return {
|
||||
key: key,
|
||||
hasTranscodeCache: fs.existsSync(hlsDir)
|
||||
hasTranscodeCache: fs.existsSync(hlsDir),
|
||||
hasDownloadCache: fs.existsSync(tmpInputPath)
|
||||
};
|
||||
});
|
||||
|
||||
@@ -639,6 +641,26 @@ app.post('/api/clear-video-transcode-cache', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/clear-video-download-cache', async (req, res) => {
|
||||
try {
|
||||
const { bucket, key } = req.body;
|
||||
if (!bucket || !key) {
|
||||
return res.status(400).json({ error: 'Bucket and key are required' });
|
||||
}
|
||||
const safeBucket = bucket.replace(/[^a-z0-9]/gi, '_');
|
||||
const safeKeySegments = key.split('/').map(segment => segment.replace(/[^a-z0-9]/gi, '_'));
|
||||
const tmpInputPath = path.join(CACHE_DIR, `s3-input-${safeBucket}-${safeKeySegments.join('-')}.tmp`);
|
||||
|
||||
if (fs.existsSync(tmpInputPath)) {
|
||||
fs.rmSync(tmpInputPath, { force: true });
|
||||
}
|
||||
res.json({ message: 'Download cache cleared for video' });
|
||||
} catch (error) {
|
||||
console.error('Error clearing video download cache:', error);
|
||||
res.status(500).json({ error: 'Failed to clear download cache', detail: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/stop-transcode', (req, res) => {
|
||||
try {
|
||||
const { key } = req.body;
|
||||
|
||||
Reference in New Issue
Block a user