mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
chore: cleanup
This commit is contained in:
@@ -291,15 +291,15 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
localSegmentPaths.push(segmentFile);
|
localSegmentPaths.push(segmentFile);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await downloadSegment(segment, segmentFile, headers, downloadId, () => {
|
await downloadSegment(downloadId, segment, segmentFile, headers);
|
||||||
segmentsDownloaded++;
|
|
||||||
updateProgress();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (getCancellationFlag(downloadId)) {
|
if (getCancellationFlag(downloadId)) {
|
||||||
await cleanupDownload(segmentDir, downloadId);
|
await cleanupDownload(segmentDir, downloadId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
segmentsDownloaded++;
|
||||||
|
updateProgress();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
if (getCancellationFlag(downloadId)) {
|
if (getCancellationFlag(downloadId)) {
|
||||||
@@ -326,11 +326,10 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const downloadSegment = async (
|
const downloadSegment = async (
|
||||||
|
downloadId: string,
|
||||||
segmentUrl: string,
|
segmentUrl: string,
|
||||||
segmentFile: string,
|
segmentFile: string,
|
||||||
headers: Record<string, string>,
|
headers: Record<string, string>,
|
||||||
downloadId: string,
|
|
||||||
onSegmentDownloadComplete: () => void,
|
|
||||||
) => {
|
) => {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
const task = download({
|
const task = download({
|
||||||
@@ -342,7 +341,6 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
|
|
||||||
task
|
task
|
||||||
.done(() => {
|
.done(() => {
|
||||||
onSegmentDownloadComplete();
|
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.error((error) => {
|
.error((error) => {
|
||||||
|
Reference in New Issue
Block a user