ygrek / mldonkey

cross-platform multi-network p2p daemon (previously at http://mldonkey.sourceforge.net/)
Other
247 stars 46 forks source link

How to recreate empty temp files? #84

Open alganza opened 2 years ago

alganza commented 2 years ago

Is there a way to recreate empty temp files? I use BTRFS as my file system and I've set the no Copy-on-Write attribute to my MLDonkey temp directory, but it does apply that attribute only to new files, but not to already existing ones. I've tried moving them to a different directory and then back to the temp directory, but that doesn't give them the -C flag attribute, since the file is still the same (already existing when the -C flag was set. Copying the files into new ones doesn't work, either, since MLDonkey doesn't seem to recognize them as the same files and it gives only problems.

The only way I've managed to get the -C flag attribute to be applied to existing temp files is to cancel the download within MLDonkey and create it again. Since I have many temp files already, it'd be a real pain to have to manually cancel and re-create the downloads again. Therefore my question: is there a way to have MLDonkey re-create the empty files within the temp directory for me?

If that isn't possible, is there a way to extract the downloading links to many files at once? That way I could cancel all of them and add them all at once through the download window (DL button).

Thank you in advance for any help/advice.

Cheers. Ángel

lulol commented 2 years ago

Stopping the core before removing and then recreating the empty files (with 0 downloaded bytes) prior to starting it again they should be recognized and not cause trouble, but don't know the particularities of BTRFS.

Currently [1] don't know if there is a better way to extract all the downloading links than using the vd <n> command one by one. Unfortunately listing all downloading files with vd doesn't list the links.

You can send the commands via script using mldonkey_command or directly querying the webgui.

Assuming ed2k links:

#LIST=$(seq 1 123)
LIST="1 2 3 5 7 11 13"
for N in $LIST; do
  curl -s "http://${USER}:${PASSWORD}@${HOST}:4080/submit?q=vd+${N}" \
  | sed -ne "s#^.*\(ed2k://|file|[^<]*\)<.*#\1#p"
done >> my_elinks.txt

Alternatively all the download links are listed in the files.ini file that you can parse directly.


[1] The old Sancho GUI can get the links for all the selected files all at once.

alganza commented 2 years ago

Alternatively all the download links are listed in the files.ini file that you can parse directly.

Thank you, lulol! Where in the files.ini file can I find the download links? I can find the file names, the md4 sums, and a few other info fields, but I fail to find the download links.

alganza commented 2 years ago

LIST=$(seq 1 123)

LIST="1 2 3 5 7 11 13" for N in $LIST; do curl -s "http://${USER}:${PASSWORD}@${HOST}:4080/submit?q=vd+${N}" \ | sed -ne "s#^.(ed2k://|file|[^<])<.*#\1#p" done >> my_elinks.txt

That works beautifully, thank you! I was typing my reply to thank you, but also to complain that I was missing four links. Fortunately I've realized I have some Bittorrent downloads as well as e2dk; I checked and there are exactly four of them. So, I 'm good to go. Thank you very much!

Now just I need to find the way to cancel all 0% downloaded files (not one by one through the web interface) and restart them from my_elinks.txt file. :)

lulol commented 2 years ago

You can cancel all the downloads sending guess what command via the webgui input box: cancel all :)

If you only want to cancel those in the list you already built to get the elinks in the LIST variable, just use the cancel <n> command instead vd <n> in a script like before.

LIST="1 2 3 5 7 11 13"
for N in $LIST; do
  curl -s "http://${USER}:${PASSWORD}@${HOST}:4080/files?cancel=+${N}" -o /dev/null
done

EDIT: I typed the wrong command. Corrected now.

alganza commented 2 years ago

You can cancel all the downloads sending guess what command via the webgui input box: cancel all :)

Thank you! Unfortunately, that won't help, because I wouldn't like the files which are already being downloaded to get cancel. Some of them have been downloading for months or even years and I wouldn't like to have to start over again with them. I rather pay the price of not having the +C (not Copy-on-Write) flag on them than starting over.

If you only want to cancel those in the list you already built to get the elinks in the LIST variable, just use the cancel <n> command instead vd <n> in a script like before.

Unfortunately, that won't help either, because I didn't build a LIST variable with only the 0% downloaded files, since they are too many, but with all my downloads. Therefore, if I used the same LIST variable, I'd get the same result I'd get with the 'cancel all' command. That's why I said I need to find a way to cancel the files which haven't started downloading yet.

I've also tried clicking on the 'Clear all' button on the web interface with the intention to select everything to be cancelled and manually deselect the ones that have already started to be downloaded and I want to keep (they are many less than the ones I don't), but alas it won't work for me. Weirdly enough, the 'Pause all' and 'Resume all' buttons work just fine, but not 'Clear all'.

lulol commented 2 years ago

That is because 'Clear all' clears all the check marks. Unfortunately there is no 'Set all' button, although the functionality is built in the embedded javascript code.

You can set all check marks opening a webconsole (in Firefox press F12) and typing at the prompt:

clearAll(true) sets all check marks cancelAll(true) sets all the cancel check marks

Then you can make the needed changes before pressing submit to confirm.

alganza commented 2 years ago

That is because 'Clear all' clears all the check marks. Unfortunately there is no 'Set all' button, although the functionality is built in the embedded javascript code.

Oh, I see. I always assumed that it was actually supposed to cancel all. Whenever I clicked on it I had nothing selected, so there was nothing to clear and I thought it was somehow broken. :-)

You can set all check marks opening a webconsole (in Firefox press F12) and typing at the prompt:

clearAll(true) sets all check marks cancelAll(true) sets all the cancel check marks

Then you can make the needed changes before pressing submit to confirm.

I didn't find the way to do that in Chromium and had started selecting files to cancel by hand already when I read this, so I kept going and select them all in the end. It's taken me a few minutes of tedious repetitive work, but I think it's been worth it. I know have all the files for downloads that are at 0% with the +C flag, which was the objective. Yay!

I should start seeing a performance increase soon-ish, when some files (without the +C flag) end downloading and new ones (with the +C flag) start downloading.

Thanks a lot for all your help. It'd had been much more tedious without it! :-)