Empty file in torrent causes infinite loop
See original GitHub issueCreating a v2 torrent from a folder with an empty file causes an infinite loop in MerkleHash.TryHash()
because src.Length == 0
. This test repros the problem in master and release-v3.0.0-beta-0034.
[TestFixture]
public class EmptyFileInTorrentTests
{
[Test]
public void EmptyFileInTorrent ()
{
var dir = new DirectoryInfo ("Data");
if (!dir.Exists)
dir.Create ();
var emptyFile = new FileInfo (Path.Combine (dir.FullName, "Empty.file"));
File.WriteAllText (emptyFile.FullName, "");
var nonEmptyFile = new FileInfo (Path.Combine (dir.FullName, "NonEmpty.file"));
File.WriteAllText (nonEmptyFile.FullName, "aoeuaoeu");
emptyFile.Refresh ();
Assert.AreEqual (0, emptyFile.Length);
ITorrentFileSource fileSource = new TorrentFileSource (dir.FullName);
TorrentCreator torrentCreator = new TorrentCreator (TorrentType.V1V2Hybrid);
var creationTask = torrentCreator.CreateAsync (fileSource);
bool completed = creationTask.Wait (10000);
Assert.IsTrue (completed);
var torrent = creationTask.Result;
Assert.IsNotNull (torrent);
}
}
I spent some time debugging, but I don’t know enough about how empty files are supposed to be hashed to provide a fix. If there’s more I can do to help diagnose, please let me know. Thanks for your help!
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
azureus infinite loop stuck at 99.9% download
I've seen this with more than one client, usually the download will progress as usual but then at the very end it will...
Read more >Flushing to disk continues indefinitely - Troubleshooting
One solution is to allow the multi-file torrent to start downloading all the files, then go to the "Files" tab and mark the...
Read more >After download, folder is empty : r/torrents
Using Qbit, and after downloading a particular torrent the folder is always empty despite being able to see the amount downloaded and the ......
Read more >qBittorrent GUI "not responding" frequently · Issue #15822
When I launch the Torrent Download window from a magnet link or a torrent metadata file. Occasionally, when statistical values are updated.
Read more >FilePointer gets stuck in infinite loop
The reason it loops forever is the first one: you are reading from the file but not checking if that works. If your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the fix! Things are looking good!
Are there plans for an updated beta nuget package? If not, I can build my own, but hoping maybe it’s as simple as 1 CI click for you. Thanks again!
Thanks for the idea. I’m happy to submit a PR with integration tests if you’re willing to make them pass. I’m not familiar enough with the details of the library to be likely to fix something without introducing new bugs. It looks like most of the existing tests are more focused unit tests, so I’ll create a new project unless you have a better idea where to put them.