alanmcgovern / monotorrent

The official repository for MonoTorrent, a bittorrent library for .NET
https://github.com/alanmcgovern/monotorrent
MIT License
1.15k stars 397 forks source link

Using SetPriority to exclude files #703

Open paulmortlock opened 1 month ago

paulmortlock commented 1 month ago

I saw an example on the wiki but this does not work.

image

paulmortlock commented 1 month ago

image

kaedei commented 3 weeks ago

Pass ITorrentManagerFile to SetFilePriorityAsync()

await torrentManager.SetFilePriorityAsync(torrentManager.Files[0], Priority.DoNotDownload);
paulmortlock commented 3 weeks ago

That does not make sense to me show me please if there is also a way to do this without using foreach as it is slow when 14K files are present.

paulmortlock commented 3 weeks ago

This is better but I have 87K files.

                var tasks = manager.Files
                .Where(files => !StartsWithStrings.Any(prefix => files.Path.StartsWith(prefix)) ||
                                !ContainsStrings.Any(prefix => files.Path.Contains(prefix)))
                .Select(async files =>
                {
                    await manager.SetFilePriorityAsync(files, Priority.DoNotDownload);
                    n2--;
                });
                await Task.WhenAll(tasks);