mirror of
https://github.com/blackjack4494/yt-dlc.git
synced 2024-12-22 07:43:08 +00:00
Fix wrong variable in position swap corrupting archive list
It's always a simple error in the end, you know? Signed-off-by: Jody Bruchon <jody@jodybruchon.com>
This commit is contained in:
parent
fda63a4e87
commit
a4d834fb3e
1 changed files with 2 additions and 4 deletions
|
@ -423,17 +423,15 @@ class YoutubeDL(object):
|
||||||
raise
|
raise
|
||||||
lmax = len(lines)
|
lmax = len(lines)
|
||||||
if lmax > 10:
|
if lmax > 10:
|
||||||
# Populate binary search tree by splitting the archive list in half
|
|
||||||
# and then adding from the outside edges inward
|
|
||||||
# This mitigates the worst case where the archive has been sorted
|
|
||||||
pos = 0
|
pos = 0
|
||||||
while pos < lmax:
|
while pos < lmax:
|
||||||
if lmax - pos <= 2:
|
if lmax - pos <= 2:
|
||||||
break
|
break
|
||||||
target = random.randrange(pos + 1, lmax - 1)
|
target = random.randrange(pos + 1, lmax - 1)
|
||||||
|
# Swap line at pos with randomly chosen target
|
||||||
temp = lines[pos]
|
temp = lines[pos]
|
||||||
lines[pos] = lines[target]
|
lines[pos] = lines[target]
|
||||||
lines[target] = lines[pos]
|
lines[target] = temp
|
||||||
pos += 1
|
pos += 1
|
||||||
elif lmax < 1:
|
elif lmax < 1:
|
||||||
# No lines were loaded
|
# No lines were loaded
|
||||||
|
|
Loading…
Reference in a new issue