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",
|
"@koa/cors": "^3.1.0",
|
||||||
"@types/mongoose": "^5.11.97",
|
"@types/mongoose": "^5.11.97",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
|
"handbrake-js": "^6.0.0",
|
||||||
"koa": "^2.13.4",
|
"koa": "^2.13.4",
|
||||||
"koa-bodyparser": "^4.3.0",
|
"koa-bodyparser": "^4.3.0",
|
||||||
"koa-json": "^2.0.2",
|
"koa-json": "^2.0.2",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ router.post('/room', async (ctx) => {
|
|||||||
const doc = new RoomModel(room);
|
const doc = new RoomModel(room);
|
||||||
|
|
||||||
torrent.on('done', function () {
|
torrent.on('done', function () {
|
||||||
|
torrent.destroy();
|
||||||
processDownloaded(torrent, room.id);
|
processDownloaded(torrent, room.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -77,6 +78,12 @@ router.get('/status', async (ctx) => {
|
|||||||
const room = await RoomModel.findOne({ id: ctx.request.query.id }).exec();
|
const room = await RoomModel.findOne({ id: ctx.request.query.id }).exec();
|
||||||
|
|
||||||
if (room) {
|
if (room) {
|
||||||
|
if (room.downloaded) {
|
||||||
|
ctx.body = {
|
||||||
|
progress: 1,
|
||||||
|
downloaded: room.downloaded,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
const torrent = tCli.get(room.magnet);
|
const torrent = tCli.get(room.magnet);
|
||||||
if (torrent) {
|
if (torrent) {
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
@@ -86,6 +93,7 @@ router.get('/status', async (ctx) => {
|
|||||||
} else {
|
} else {
|
||||||
({ status: ctx.status, body: ctx.body } = errorResponse('status-00', 'No torrent found'));
|
({ status: ctx.status, body: ctx.body } = errorResponse('status-00', 'No torrent found'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
({ status: ctx.status, body: ctx.body } = errorResponse('status-01', 'No room found'));
|
({ status: ctx.status, body: ctx.body } = errorResponse('status-01', 'No room found'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user