Skip to content

Implement fine grained priorities#23751

Draft
HanabishiRecca wants to merge 1 commit intoqbittorrent:masterfrom
HanabishiRecca:priorities
Draft

Implement fine grained priorities#23751
HanabishiRecca wants to merge 1 commit intoqbittorrent:masterfrom
HanabishiRecca:priorities

Conversation

@HanabishiRecca
Copy link
Contributor

@HanabishiRecca HanabishiRecca commented Jan 17, 2026

A small PoC code to close #21430.
I'm not really happy with the current implementation, it's just to give the idea.

Comment on lines 35 to 46
switch (priority)
{
case DownloadPriority::Ignored:
case DownloadPriority::Normal:
case DownloadPriority::Normal2:
case DownloadPriority::Normal3:
case DownloadPriority::Normal4:
case DownloadPriority::Normal5:
case DownloadPriority::High:
case DownloadPriority::Maximum:
case DownloadPriority::Mixed:
return true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the indexes are contiguous now, I think in such places switches can be replaced with more generalized code.

Comment on lines 35 to 42
Ignored = 0,
Normal = 1,
Normal2 = 2,
Normal3 = 3,
Normal4 = 4,
Normal5 = 5,
High = 6,
Maximum = 7,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the naming here, but not sure if we can change the defaults.
Probably makes more sense to shift default Normal level to 4 (as libtorrent implies internally) and then introduce low/normal/high levels.
That should not break backward compatibility in theory, files in old torrents will just appear as "low" priority, which is not a big deal.

@cbordeman
Copy link

cbordeman commented Jan 17, 2026

Since these are internal names and they may be expanded in the future (LibTorrent's enum), can I suggest the following enums?
Ignored = 0,
Priority1 = 1,
Priority2 = 2,
Priority3 = 3,
Priority4 = 4,
Priority5 = 5,
Priority6 = 6,
Priority7 = 7

In the UI, I'd show them as:
Do Not Download, Lowest (1), Lower (2), Lower (3), Normal (4), Higher (5), Higher (6), Highest (7)

@HanabishiRecca
Copy link
Contributor Author

Changing internal names in the future is not a problem. If fact I'm not sure if we even need an enum at this point. When indexes are contiguous we could store it as a plain number, define some low/normal/high consts (basically what libtorrent does) and automatically generate names in between.

@cbordeman
Copy link

cbordeman commented Jan 18, 2026

Yep, an int would be better and wouldn't need to be adjusted.

@glassez
Copy link
Member

glassez commented Jan 18, 2026

@HanabishiRecca
I would rather "play the long game" in this matter, i.e. propose changes to the libtorrent so that it supports plain numerical priorities that are not limited by the current maximum value. Applications could still implement a limited set of priorities (e.g. Low, Normal, High, if they need it) on top of it.

@HanabishiRecca
Copy link
Contributor Author

Yeah, idk why libtorrent has limited priorities in the first place. Looks easier to just let clients set arbitrary number.
We kinda have the report for that arvidn/libtorrent#8120

@cbordeman
Copy link

cbordeman commented Jan 18, 2026

Perhaps the libtorrent max isn't actually enforced...

EDIT: Never mind, yeah it is.

@cbordeman
Copy link

@glassez A byte would be more than enough.

@dbny89
Copy link

dbny89 commented Feb 4, 2026

Since these are internal names and they may be expanded in the future (LibTorrent's enum), can I suggest the following enums? Ignored = 0, Priority1 = 1, Priority2 = 2, Priority3 = 3, Priority4 = 4, Priority5 = 5, Priority6 = 6, Priority7 = 7

In the UI, I'd show them as: Do Not Download, Lowest (1), Lower (2), Lower (3), Normal (4), Higher (5), Higher (6), Highest (7)

Love this idea, but still want 15 priorities as in utorrent

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.

Use Fine Grained File Priorities

4 participants