Skip to content

Milestone 1 v2 stabilization - #2654

Open
cyberlog69 wants to merge 3 commits into
JunkFood02:mainfrom
cyberlog69:milestone-1-v2-stabilization
Open

cyberlog69 wants to merge 3 commits into
JunkFood02:mainfrom
cyberlog69:milestone-1-v2-stabilization

Conversation

@cyberlog69

Copy link
Copy Markdown

PR Title

feat: Milestone 1 - DownloaderV2 stabilization, legacy V1 retirement, and test coverage


Description

Overview

This PR completes Milestone 1 of the v2.0 architecture overhaul. It fully deprecates and removes the legacy single-job Downloader (V1) components, migrates all remaining pages and background receivers to DownloaderV2, refines custom command execution and restart logic, adds multi-task notification action handling (cancel/restart), and introduces comprehensive unit tests for task states, transitions, and queue serialization.

Net result: -1,103 lines of obsolete code removed while providing full concurrency support and test coverage.


Key Changes

1. 🗑️ Legacy V1 Retirement & Technical Debt Cleanup

  • Safely deleted obsolete V1 classes:
    • Removed legacy single-job Downloader.kt (-573 lines).
    • Removed legacy DownloadPage.kt (-805 lines) and HomePageViewModel.kt (-145 lines).
    • Removed stale imports and references from App.kt and AppEntry.kt.
  • Migrated command & utility pages:
    • TaskListPage.kt: Switched task listing, creation, and cancellation to use DownloaderV2.getTaskStateMap(), enqueue(), and cancel().
    • TaskLogPage.kt: Updated live log viewing, process cancellation, and restart handling to read from and dispatch to DownloaderV2.
    • YtdlpUpdater.kt: Replaced checks against legacy Downloader.downloaderState with active queue inspection from DownloaderV2.

2. ⚡ DownloaderV2 Polish & Notification Actions

  • Custom Command Lifecycle & Restart Fix (DownloaderV2.kt):
    • Fixed Task.download() to evaluate and execute custom commands prior to null-checking info (commands don't have video metadata).
    • Updated Task.execute() to accept both Idle (fresh start) and ReadyWithInfo (restart after cancel/error).
  • Multi-Task Notification Handling:
    • Added ACTION_RESTART_TASK support to NotificationActionReceiver.kt so individual tasks can be restarted straight from error notifications.
    • Updated NotificationUtil.kt to accept a taskId in notifyError and attach a Restart action alongside the error report button.

3. 🧪 Testing & Quality Assurance

  • TaskFactoryTest.kt: Unit tests for playlist item extraction and custom command factory methods.
  • TaskStateTransitionTest.kt:
    • Tests queue priority sorting (Running < ReadyWithInfo < FetchingInfo < Idle < Canceled < Error < Completed).
    • Validates state transitions and restart action mapping (FetchInfo -> Idle, Download -> ReadyWithInfo).
    • Validates custom command lifecycle states.
  • TaskBackupRestoreTest.kt:
    • Tests Map<Task, Task.State> serialization and deserialization via Kotlinx Serialization (allowStructuredMapKeys = true).
    • Tests queue recovery logic in enqueueFromBackup().

Verification & Testing

  • Ran :app:testGenericDebugUnitTest across all test classes:
    • TaskFactoryTest: PASSED
    • TaskStateTransitionTest: PASSED
    • TaskBackupRestoreTest: PASSED
    • ExampleUnitTest: PASSED
  • Verified build and packaging with Java 21 / AGP 8.10.

Diff Summary

20 files changed, 615 insertions(+), 1718 deletions(-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant