If a video fails to download, move it to the end of the queue

This commit is contained in:
Gergely Hegedus 2025-09-04 13:53:31 +03:00
parent 45fb0d4d71
commit 767cd1aa67

View file

@ -108,24 +108,36 @@ class VideoDownloadingProcessorUseCase(
ProcessState.Processed(videoDownloaded)
} catch (networkException: NetworkException) {
moveAtTheEndOfList(videoInPending)
ProcessState.NetworkError
} catch (parsingException: ParsingException) {
moveAtTheEndOfList(videoInPending)
ProcessState.ParsingError
} catch (videoDeletedException: VideoDeletedException) {
moveAtTheEndOfList(videoInPending)
ProcessState.VideoDeletedError
} catch (videoPrivateException: VideoPrivateException) {
moveAtTheEndOfList(videoInPending)
ProcessState.VideoPrivateError
} catch (storageException: StorageException) {
moveAtTheEndOfList(videoInPending)
ProcessState.StorageError
} catch (captchaRequiredException: CaptchaRequiredException) {
moveAtTheEndOfList(videoInPending)
captchaTimeoutLocalSource.onCaptchaResponseReceived()
ProcessState.CaptchaError
} catch (throwable: Throwable) {
moveAtTheEndOfList(videoInPending)
ProcessState.UnknownError
} finally {
videoInProgressLocalSource.removeVideoAsInProgress(videoInPending)
}
private fun moveAtTheEndOfList(videoInPending: VideoInPending) {
videoInPendingLocalSource.removeVideoFromQueue(videoInPending)
videoInPendingLocalSource.saveUrlIntoQueue(videoInPending)
}
private enum class ProcessingState {
RUNNING, ERROR
}