If a video fails to download, move it to the end of the queue
This commit is contained in:
parent
45fb0d4d71
commit
767cd1aa67
1 changed files with 12 additions and 0 deletions
|
|
@ -108,24 +108,36 @@ class VideoDownloadingProcessorUseCase(
|
||||||
|
|
||||||
ProcessState.Processed(videoDownloaded)
|
ProcessState.Processed(videoDownloaded)
|
||||||
} catch (networkException: NetworkException) {
|
} catch (networkException: NetworkException) {
|
||||||
|
moveAtTheEndOfList(videoInPending)
|
||||||
ProcessState.NetworkError
|
ProcessState.NetworkError
|
||||||
} catch (parsingException: ParsingException) {
|
} catch (parsingException: ParsingException) {
|
||||||
|
moveAtTheEndOfList(videoInPending)
|
||||||
ProcessState.ParsingError
|
ProcessState.ParsingError
|
||||||
} catch (videoDeletedException: VideoDeletedException) {
|
} catch (videoDeletedException: VideoDeletedException) {
|
||||||
|
moveAtTheEndOfList(videoInPending)
|
||||||
ProcessState.VideoDeletedError
|
ProcessState.VideoDeletedError
|
||||||
} catch (videoPrivateException: VideoPrivateException) {
|
} catch (videoPrivateException: VideoPrivateException) {
|
||||||
|
moveAtTheEndOfList(videoInPending)
|
||||||
ProcessState.VideoPrivateError
|
ProcessState.VideoPrivateError
|
||||||
} catch (storageException: StorageException) {
|
} catch (storageException: StorageException) {
|
||||||
|
moveAtTheEndOfList(videoInPending)
|
||||||
ProcessState.StorageError
|
ProcessState.StorageError
|
||||||
} catch (captchaRequiredException: CaptchaRequiredException) {
|
} catch (captchaRequiredException: CaptchaRequiredException) {
|
||||||
|
moveAtTheEndOfList(videoInPending)
|
||||||
captchaTimeoutLocalSource.onCaptchaResponseReceived()
|
captchaTimeoutLocalSource.onCaptchaResponseReceived()
|
||||||
ProcessState.CaptchaError
|
ProcessState.CaptchaError
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
|
moveAtTheEndOfList(videoInPending)
|
||||||
ProcessState.UnknownError
|
ProcessState.UnknownError
|
||||||
} finally {
|
} finally {
|
||||||
videoInProgressLocalSource.removeVideoAsInProgress(videoInPending)
|
videoInProgressLocalSource.removeVideoAsInProgress(videoInPending)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun moveAtTheEndOfList(videoInPending: VideoInPending) {
|
||||||
|
videoInPendingLocalSource.removeVideoFromQueue(videoInPending)
|
||||||
|
videoInPendingLocalSource.saveUrlIntoQueue(videoInPending)
|
||||||
|
}
|
||||||
|
|
||||||
private enum class ProcessingState {
|
private enum class ProcessingState {
|
||||||
RUNNING, ERROR
|
RUNNING, ERROR
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue