Skip to content

Instantly share code, notes, and snippets.

@lukaville
Created June 9, 2020 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaville/02b4b359786b34f33d0b962f3bc86768 to your computer and use it in GitHub Desktop.
Save lukaville/02b4b359786b34f33d0b962f3bc86768 to your computer and use it in GitHub Desktop.
Patch transmission for sequential download
#!/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