mirror of
https://github.com/anatolykopyl/movieroom-core.git
synced 2026-03-26 12:54:51 +00:00
Destroy downloaded
This commit is contained in:
813
package-lock.json
generated
813
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@
|
||||
"@koa/cors": "^3.1.0",
|
||||
"@types/mongoose": "^5.11.97",
|
||||
"dotenv": "^10.0.0",
|
||||
"handbrake-js": "^6.0.0",
|
||||
"koa": "^2.13.4",
|
||||
"koa-bodyparser": "^4.3.0",
|
||||
"koa-json": "^2.0.2",
|
||||
|
||||
16
src/index.ts
16
src/index.ts
@@ -35,6 +35,7 @@ router.post('/room', async (ctx) => {
|
||||
const doc = new RoomModel(room);
|
||||
|
||||
torrent.on('done', function () {
|
||||
torrent.destroy();
|
||||
processDownloaded(torrent, room.id);
|
||||
});
|
||||
|
||||
@@ -77,14 +78,21 @@ router.get('/status', async (ctx) => {
|
||||
const room = await RoomModel.findOne({ id: ctx.request.query.id }).exec();
|
||||
|
||||
if (room) {
|
||||
const torrent = tCli.get(room.magnet);
|
||||
if (torrent) {
|
||||
if (room.downloaded) {
|
||||
ctx.body = {
|
||||
progress: (torrent as WebTorrent.Torrent).progress,
|
||||
progress: 1,
|
||||
downloaded: room.downloaded,
|
||||
};
|
||||
} else {
|
||||
({ status: ctx.status, body: ctx.body } = errorResponse('status-00', 'No torrent found'));
|
||||
const torrent = tCli.get(room.magnet);
|
||||
if (torrent) {
|
||||
ctx.body = {
|
||||
progress: (torrent as WebTorrent.Torrent).progress,
|
||||
downloaded: room.downloaded,
|
||||
};
|
||||
} else {
|
||||
({ status: ctx.status, body: ctx.body } = errorResponse('status-00', 'No torrent found'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
({ status: ctx.status, body: ctx.body } = errorResponse('status-01', 'No room found'));
|
||||
|
||||
Reference in New Issue
Block a user