Hello,
I don't know Python, else I would try to implement it myself.
Compact allocation could be better implemented, so priority could work. I think today it is implemented so as to fill each block sequentially from the first file of the torrent up to the last. Deluge must mantain a block table. When a new block is allocated, if the new content belongs to a previously allocated block, this block is copied to the new allocated block and the content begins downloading in his proper block.
A better allocation suggests that blocks should be downloaded directly in the proper files. Lets say I have a torrent with 6 files:
filea 37M
fileb 2M
filec 3M
filed 20M
filee 5M
filef 20M
Lets say a block size is 9M, the blocks should be known as:
filea [block1 9M][block2 9M][block3 9M][block4 9M][block5a 1M]
fileb [block5b 2M]
filec [block5c 3M]
filed [block5d 3M][block6 9M][block7a 8M]
filee [block7b 1M][block8a 4M]
filef [block8b 5M][block9 9M][block10 6M]
Now let's say I start downloading block 7.
Deluge should compactly allocate blocks in 'filed' and afterwards, 'filee':
filed [block5d 3M][block7a 8M]
filee [block7b 1M]
This way, you could have both a way to check if the block is downloaded, and compact allocation. It doesn't matter if block5d would be left empty. The lost space is definitely less than if full allocation is being used.
If afterwards, Deluge starts downloading block 6, it can allocate the space at the end of 'filed', copy the content of 'block7a' to the end of 'filed' and start downloading block6. The downloaded files should resemble this:
filed [block5d 3M][block6 9M][block7a 8M]
filee [block7b 1M]
If you would have also a way to reallocate the blocks between files, freeing the space of unallocated blocks, you could implement compact allocation easily.
Best regards, great product.