mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-13 11:53:41 +00:00
fix(bt): honor selected files when creating resolved tasks
This commit is contained in:
1 parent
16f2d30476
commit
5bb040eaaf
11 files changed
+265
-20
No files matched your search
@@ -36,8 +36,15 @@ enum TaskAssetType {
|
||||
}
|
||||
|
||||
class TaskFileNode {
|
||||
const TaskFileNode({required this.path, required this.name, required this.sizeBytes, this.downloadedBytes});
|
||||
const TaskFileNode({
|
||||
required this.path,
|
||||
required this.name,
|
||||
required this.sizeBytes,
|
||||
this.downloadedBytes,
|
||||
this.resourceIndex,
|
||||
});
|
||||
|
||||
final int? resourceIndex;
|
||||
final String path;
|
||||
final String name;
|
||||
final int sizeBytes;
|
||||
@@ -146,7 +153,7 @@ class TaskRecord {
|
||||
totalBytes: totalBytes > 0 ? totalBytes : null,
|
||||
speedBytes: task.progress.speed,
|
||||
uploadedBytes: task.progress.uploaded,
|
||||
files: _fileNodes(task.meta.res?.files),
|
||||
files: _fileNodes(task.meta.res?.files, task.meta.opts.selectFiles),
|
||||
uploading: task.uploading,
|
||||
isFolder: task.meta.res?.name.isNotEmpty ?? false,
|
||||
protocol: task.protocol,
|
||||
@@ -313,12 +320,23 @@ int? _remainingSeconds(api_task.Task task, int totalBytes, int downloadedBytes)
|
||||
return ((totalBytes - downloadedBytes) / speed).ceil();
|
||||
}
|
||||
|
||||
List<TaskFileNode> _fileNodes(List<api_resource.FileInfo>? files) {
|
||||
List<TaskFileNode> _fileNodes(List<api_resource.FileInfo>? files, List<int> selectedIndexes) {
|
||||
if (files == null || files.isEmpty) {
|
||||
return const [];
|
||||
}
|
||||
final selected = selectedIndexes.toSet();
|
||||
return files
|
||||
.map((file) => TaskFileNode(path: file.path, name: file.name, sizeBytes: file.size))
|
||||
.asMap()
|
||||
.entries
|
||||
.where((entry) => selected.isEmpty || selected.contains(entry.key))
|
||||
.map(
|
||||
(entry) => TaskFileNode(
|
||||
resourceIndex: entry.key,
|
||||
path: entry.value.path,
|
||||
name: entry.value.name,
|
||||
sizeBytes: entry.value.size,
|
||||
),
|
||||
)
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class _TaskFileTreeState extends State<TaskFileTree> {
|
||||
.entries
|
||||
.map(
|
||||
(entry) => FileTreeItem<TaskFileNode>(
|
||||
key: entry.key.toString(),
|
||||
key: (entry.value.resourceIndex ?? entry.key).toString(),
|
||||
path: entry.value.path,
|
||||
name: entry.value.name,
|
||||
size: entry.value.sizeBytes,
|
||||
|
||||
Reference in new issue
Block a user