Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   Download/Upload Problems (https://www.gnutellaforums.com/download-upload-problems/)
-   -   Somewhat of a solution for resuming downloads (https://www.gnutellaforums.com/download-upload-problems/14015-somewhat-solution-resuming-downloads.html)

Unregistered July 29th, 2002 01:56 PM

Somewhat of a solution for resuming downloads
 
Well, I got sick and tired of watching a nearly finished download stall, then restart under a slightly different name, even when the file sizes were exactly the same. Jeez, this should just work.

So here's a bit of a hack solution: this is a simple shell script that will create symbolic links of all files that share the same prefix with the target file that you specify. In other words, you type:

combine.sh "T-98721-Some Thing.file"

and every file that has the same "T-XXXXX" will be deleted (or moved, if you want to play it safe) and a symbolic link will be created in its stead. All you need to do is supply the filename of your target.

I haven't fully tested this out to see if it works without introducing artifacts, so be forewarned. Oh, and this is for Linux, sorry to Windows users, but it should also work under OSX if you have bash. I'd appreciate comments and improvements to **EDIT EMAIL ADDRESS**
Good luck.

-----BEGIN SCRIPT-----
#!/bin/bash
# This file is used to link similar files to a target file. It is
# intended to be used with Limewire to facilitate downloads.

function print_usage {
echo "Usage: $( basename $0 ) [-s] filename"
echo -e "\t-s\tbackup files"
echo "Remember to surround files that include whitespace with quotes"
exit $E_WRONGARGS
}

TARGET=temp # Target file to link to
PREFIX=temp # Prefix of target file used for search
SAFEMODE=false # Indicate whether to backup files
E_WRONGARGS=65 # Improper arguments
E_NOTARGET=66 # Target file does not exist
E_NODELETE=67 # Cannot delete file
E_NOMOVE=68 # Cannot move file
E_NOLINK=69 # Cannot link files

# Save stdin
exec 6<&0

# Test for appropriate arguments
if [ -z "$1" ]; then
print_usage
elif [ "$1" = "-s" ]; then
if [ -z "$2" ]; then
print_usage
else
SAFEMODE=true
TARGET="$2"
fi
else
TARGET="$1"
fi

# Test for existence of target file
if [ ! -f "$TARGET" ]; then
echo "Target file does not exist"
exit $E_NOTARGET
fi

# Create backup directory if applicable
if [ "$SAFEMODE" = "true" -a ! -d "backup" ]; then
mkdir backup
if [ ! "$?" ]; then
echo "Cannot create backup directory"
echo "Check directory permissions"
exit $E_FAILBACKUP
fi
fi

# Strip prefix from target file
PREFIX=$( echo $TARGET | cut -d- -f1,2 - )

# Perform search for prefix and store in a temp file
ls | grep $PREFIX > files.temp

# Change stdin to files.temp and begin processing
exec < files.temp
read FILE
while [ ! -z "$FILE" ]; do
if [ "$FILE" != "$TARGET" ]; then
if [ "$SAFEMODE" = "false" ]; then
rm -f "$FILE"
if [ ! "$?" = "0" ]; then
echo "Unable to delete $FILE"
echo "Check permissions"
echo "Exiting"
exit E_NODELETE
fi
else
mv "$FILE" ./backup/
if [ ! "$?" = "0" ]; then
echo "Unable to move $FILE"
echo "Check permissions"
echo "Exiting"
exit E_NOMOVE
fi
fi
ln -s "$TARGET" "$FILE"
if [ ! "$?" = "0" ]; then
echo "Unable to link files"
echo "Check permissions"
echo "Exiting"
exit E_NOLINK
fi
fi
read FILE
done

# Restore stdin
exec 0<&6 6<&-

rm -f files.temp

echo "Done"

exit 0
-----END SCRIPT-----
Just copy and paste it into a file like:
combine.sh, make it executable with
chmod 777 combine.sh, and place it
in /usr/local/bin or whatever.

Unregistered July 31st, 2002 02:35 PM

Hmmm, after trying this out for a few more days, it seems like it doesn't work after all. In most cases, from what I can tell, downloads will most often start over rather than continuing from a linked position. I believe the problem lies instead with the downloads.dat file, which must be editable in some fashion.
Anyway, sorry for any false hopes, and if anyone has a recommendation for a better linux gnutella client, I'd like to hear it.


All times are GMT -7. The time now is 02:22 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.