feat: AdaptiveConcurrencyController

This commit is contained in:
xkeyC
2025-12-05 22:06:55 +08:00
parent 3c60b5a2c1
commit 8898569067
13 changed files with 387 additions and 62 deletions

View File

@@ -52,14 +52,14 @@ class DownloadManager extends _$DownloadManager {
// Lazy load init
() async {
await Future.delayed(const Duration(milliseconds: 16));
try {
// Check if there are existing tasks (check working dir for session data)
final dir = Directory(workingDir);
if (await dir.exists()) {
dPrint("Launch download manager");
// Check if there are pending tasks to restore (without starting the downloader)
if (downloader_api.downloaderHasPendingSessionTasks(workingDir: workingDir)) {
dPrint("Launch download manager - found pending session tasks");
await initDownloader();
} else {
dPrint("LazyLoad download manager");
dPrint("LazyLoad download manager - no pending tasks");
}
} catch (e) {
dPrint("DownloadManager.checkLazyLoad Error:$e");
@@ -246,4 +246,15 @@ class DownloadManager extends _$DownloadManager {
}
return await downloader_api.downloaderHasActiveTasks();
}
/// Get all completed tasks from cache (tasks that were removed by removeCompletedTasks)
/// This cache is cleared when the downloader is shutdown/restarted
List<downloader_api.DownloadTaskInfo> getCompletedTasksCache() {
return downloader_api.downloaderGetCompletedTasksCache();
}
/// Clear the completed tasks cache manually
void clearCompletedTasksCache() {
downloader_api.downloaderClearCompletedTasksCache();
}
}

View File

@@ -41,7 +41,7 @@ final class DownloadManagerProvider
}
}
String _$downloadManagerHash() => r'f12d3fb1d7c03fdfccff7d07903218f38a860437';
String _$downloadManagerHash() => r'55c92224a5eb6bb0f84f0a97fd0585b94f61f711';
abstract class _$DownloadManager extends $Notifier<DownloadManagerState> {
DownloadManagerState build();