Home » File Formats » File_Bittorrent » Bug #7406
MakeTorrent wont add files in directories
Details
| Submitted | 2006-04-15 23:41 UTC |
|---|---|
| From | knightar at gmail dot com |
| Assigned | tacker |
| Status | Closed |
| Package | File_Bittorrent |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2006-04-15 23:41 UTC] knightar at gmail dot com
Description:
------------
MakeTorrent wont make a torrent of all the files in a dir like the docs said it would. It comes up with no result when using a directory.
I currently have the following files in "D:/files_to_torrent/":
atvp4.exe
readme.txt
website.lnk
The same method works when adding "D:/files_to_torrent/atvp4.exe" insted.
Also, I used the php.ini-dist origional file and added include_path=".;C:\PHP\pear" to it.
Test script:
---------------
error_reporting(E_ALL);
require_once 'File/Bittorrent/MakeTorrent.php';
// Set error handling
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
$MakeTorrent = new File_Bittorrent_MakeTorrent('D:/files_to_torrent/');
// Set the announce URL
$MakeTorrent->setAnnounce('http://www.example.org');
// Set the comment
$MakeTorrent->setComment('Hello World!');
// Set the piece length (in KB)
$MakeTorrent->setPieceLength(256);
// Build the torrent
$metainfo = $MakeTorrent->buildTorrent();
echo $metainfo;
[2006-04-16 03:06 UTC] knightar at gmail dot com
I've got a quick patch after alot of debugging and ripping apart the coding. Bascily, the _addDir function was not returning anything after it was completed. I'm guessing that the function wasnt returning $this->files after the function was finished.
diff -u MakeTorrent_bk.php MakeTorrent.php
--- MakeTorrent_bk.php 2006-04-15 16:04:03.546875000 -0700
+++ MakeTorrent.php 2006-04-15 19:50:26.578125000 -0700
@@ -398,6 +398,7 @@
$this->_files[] = $filedata;
}
}
+ return true;
}
/**
[2006-04-16 03:12 UTC] knightar at gmail dot com
- OS version
- PHP Version
+ PHP Version: Irrelevant
[2006-04-16 09:52 UTC] tacker at php dot net
Hm, _addDir [1] is not expected to return something but a return value is checked in [2].
[1] http://m.tacker.org/trac/File_Bittorrent/browser/trunk/File/Bittorrent/MakeTorrent.php#L373
[2] http://m.tacker.org/trac/File_Bittorrent/browser/trunk/File/Bittorrent/MakeTorrent.php#L254
[2006-04-16 17:12 UTC] knightar at gmail dot com
Like I said, My patch was a quick fix. =] I suspected http://m.tacker.org/trac/File_Bittorrent/browser/trunk/File/Bittorrent/MakeTorrent.php#L254 had something to do with checking it, but since there wasnt anything being returned it would always false. So I took the example of http://m.tacker.org/trac/File_Bittorrent/browser/trunk/File/Bittorrent/MakeTorrent.php#L247 and put a 'return true'. Wasnt sure what it was supposed to do and all, but it works perfectly with the 'return true' on directories.
[2006-07-02 17:15 UTC] tacker at php dot net
This bug has been fixed in CVS.
If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).
If this was a problem with the pear.php.net website, the change should be live shortly.
Otherwise, the fix will appear in the package's next release.
Thank you for the report and for helping us make PEAR better.
ChangeSet: http://versions.tacker.org/trac/File_Bittorrent/changeset/56