mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-10 19:47:42 +00:00
feat(torrents): support piece priority
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
canonicalizeDownloadFileName,
|
||||
isValidTorrentExcludeTrackerList,
|
||||
isValidTorrentTrackerList,
|
||||
normalizeTorrentPrioritizePiece,
|
||||
redactDownloadForPersistence,
|
||||
resolveDownloadConnections
|
||||
} from './downloads';
|
||||
@@ -77,6 +78,20 @@ describe('Torrent tracker input validation', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Torrent piece priority validation', () => {
|
||||
it('normalizes head and tail preview policies', () => {
|
||||
expect(normalizeTorrentPrioritizePiece(' tail = 64k, HEAD ')).toBe('head,tail=64K');
|
||||
expect(normalizeTorrentPrioritizePiece('head=1m,tail=1024M')).toBe('head=1M,tail=1024M');
|
||||
expect(normalizeTorrentPrioritizePiece('')).toBeNull();
|
||||
});
|
||||
|
||||
it('rejects duplicate, unsupported, malformed, and oversized policies', () => {
|
||||
for (const value of ['head,head', 'middle', 'head=0K', 'tail=1G', 'head=1K,', 'head=1025M']) {
|
||||
expect(normalizeTorrentPrioritizePiece(value)).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('download connection resolution', () => {
|
||||
it('uses a clamped fallback for legacy rows without a saved value', () => {
|
||||
expect(resolveDownloadConnections(undefined, 8)).toBe(8);
|
||||
|
||||
Reference in New Issue
Block a user