Created
June 9, 2020 23:08
-
-
Save lukaville/02b4b359786b34f33d0b962f3bc86768 to your computer and use it in GitHub Desktop.
Patch transmission for sequential download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
git clone https://github.com/transmission/transmission | |
cd transmission | |
python <<END | |
with open('libtransmission/peer-mgr.c', 'r') as file: | |
source_code = file.readlines() | |
function_start = next(i for i, string in enumerate(source_code) if 'comparePieceByWeight' in string) | |
function_end = source_code.index('}\n', function_start) | |
patched_source_code = source_code[:(function_start + 2)] + ['\nreturn comparePieceByIndex(va, vb);\n'] + source_code[function_end:] | |
with open('libtransmission/peer-mgr.c', 'w') as file: | |
file.writelines(patched_source_code) | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment