Cant attach .torrent files
ravik - December 1, 2007 - 22:16
| Project: | BitTorrent |
| Version: | 5.x-1.0-beta |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | ravik |
| Status: | won't fix |
Jump to:
Description
Drupal 5.1
.torrent file was aded to upload file types, role permissions were set, but when in torrent node cant attach .torrent files. the error is:
A torrent file must be attached to the node OR a web-seeding path must be specified. Please attach a torrent or specify a path and try again.

#1
I've been trying to figure out what's going on for hours now -- it takes some time given that I'm not used to PHP or knowledgeable about the inner workings or Drupal, but I think I've finally made some progress.
1) After tracing a lot of variables I found that $_FILES was completely empty when I uploaded a torrent "attachment". In order for uploads to work, it seems the form encoding has to be multipart/form-data. At the end of bt_torrent_form() there's a line saying:
<?php$form['bt_options']['upload_wrapper'] += module_invoke('_upload', 'form', $node);
?>
Add the following line:
<?php$form['bt_options']['upload_wrapper'] += module_invoke('_upload', 'form', $node);
$form['#attributes'] = array('enctype' => "multipart/form-data");
?>
2) This was enough to allow me past that first step, but in order for the module to properly process the form when it is finally submitted, the upload module must run its hook_nodeapi() before the bittorrent module runs its hook. Otherwise, the following lines won't retrieve the new torrent file from the files table because the torrent file simply won't have been added to the files table yet:
<?php$torrent = db_fetch_object(db_query("SELECT f.filepath FROM {files} f WHERE nid = %d", $node->nid));
$torrent = bdecode_torrent($torrent->filepath);
?>
It seems this is one of those things that might work fine on one system but not on another, since modules with the same weight run in an arbitrary order (and on my system both upload and bt_torrent had weight 0). I increased the weight of the bt_torrent module in the system table, causing bt_torrent_nodeapi() to run after upload_nodeapi(), and now I have successfully created a couple of torrent nodes and my own client seems to be connected to the tracker. Remains to be seen whether it is possible to download anything...
#2
I have added the enctype to the form, but I still need to look into increasing the modules weight.
#3
Thanks for good work, would be really nice to see this finished.
Right now, I cant attach torrent, error message is Wrong parameter count for sha1()
I've tried to set weight from 0 to 1 but it didnt help. Same message appears.
Drupal version I'm using is 5.7
btw How to find out passkey for every user, where do you see your passkey when Private tracker option is used ?
tnx
Keep up the good work!
#4
I don't think the passkey is displayed to the user anywhere, just kept in a table internally.
Would anyone like this value displayed anywhere? Let me know...
~Chris
#5
5.x version is longer not supported.