Made it so the backend cancels streams that are rerequested by the client
This commit is contained in:
@@ -372,7 +372,7 @@ class FileController {
|
||||
|
||||
//tempStorage[req.params.uuid] = uuid.v4();
|
||||
|
||||
console.log("stream request", tempStorage)
|
||||
console.log("stream request");
|
||||
|
||||
// req.on("close", () => {
|
||||
// console.log("req closed stream");
|
||||
|
||||
@@ -256,22 +256,13 @@ class FileSystemService implements ChunkInterface {
|
||||
|
||||
readStream.pipe(decipher);
|
||||
|
||||
req.on("close", () => {
|
||||
// console.log("req closed");
|
||||
readStream.destroy();
|
||||
})
|
||||
|
||||
const tempUUID = req.params.uuid;
|
||||
|
||||
// req.on("close", () => {
|
||||
// // console.log("Destroying read stream");
|
||||
// // readStream.destroy();
|
||||
// // console.log("Read Stream Destoryed");
|
||||
// })
|
||||
|
||||
// req.on("error", () => {
|
||||
// console.log("req error");
|
||||
// })
|
||||
|
||||
// req.on("pause", () => {
|
||||
// console.log("req pause")
|
||||
// })
|
||||
|
||||
await awaitStreamVideo(start, end, differenceStart, decipher, res, tempUUID, allStreamsToErrorCatch);
|
||||
}
|
||||
|
||||
|
||||
@@ -279,6 +279,12 @@ class MongoService implements ChunkInterface {
|
||||
|
||||
readStream.pipe(decipher);
|
||||
|
||||
req.on("close", () => {
|
||||
// console.log("req closed");
|
||||
readStream.destroy();
|
||||
})
|
||||
|
||||
|
||||
const tempUUID = req.params.uuid;
|
||||
|
||||
await awaitStreamVideo(start, end, differenceStart, decipher, res, tempUUID, allStreamsToErrorCatch);
|
||||
|
||||
@@ -214,15 +214,15 @@ class S3Service implements ChunkInterface {
|
||||
// })
|
||||
|
||||
req.on("close", () => {
|
||||
console.log("req closed");
|
||||
// console.log("req closed");
|
||||
s3ReadStream.destroy();
|
||||
})
|
||||
|
||||
//req.on("")
|
||||
|
||||
req.on("end", () => {
|
||||
console.log("req end");
|
||||
})
|
||||
// req.on("end", () => {
|
||||
// console.log("req end");
|
||||
// })
|
||||
|
||||
await awaitStreamVideo(start, end, differenceStart, decipher, res, tempUUID, allStreamsToErrorCatch);
|
||||
}
|
||||
|
||||
@@ -21,18 +21,18 @@ const awaitStreamVideo = (start: number, end:number, differenceStart: number,
|
||||
//console.log(tempStorage[tempUUID] !== currentUUID, tempStorage[tempUUID])
|
||||
if (tempStorage[tempUUID] !== currentUUID) {
|
||||
|
||||
console.log("New Stream Requested, Desroying old stream");
|
||||
//console.log("New Stream Requested, Desroying old stream");
|
||||
|
||||
streamsToErrorCatch.forEach((stream) => {
|
||||
stream.destroy();
|
||||
})
|
||||
|
||||
console.log("Old Stream Desroyed");
|
||||
//console.log("Old Stream Desroyed");
|
||||
resolve();
|
||||
//delete tempStorage[tempUUID];
|
||||
}
|
||||
|
||||
console.log("stream passed", currentUUID);
|
||||
//console.log("stream passed", currentUUID);
|
||||
|
||||
// if (tempStorage[tempUUID] !== undefined && tempStorage[tempUUID] !== currentUUID) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user