From 767cd1aa67634d102ec1ad0ffcedcde84be0724f Mon Sep 17 00:00:00 2001 From: Gergely Hegedus Date: Thu, 4 Sep 2025 13:53:31 +0300 Subject: [PATCH] If a video fails to download, move it to the end of the queue --- .../data/usecase/VideoDownloadingProcessorUseCase.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt index 5dd72ab..10c7f80 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt @@ -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 }