[pacman-dev] [PATCH] makepkg: remove .part file after a failed download

Cedric Staniewski cedric at gmx.ca
Wed Oct 21 13:38:58 EDT 2009


Xavier wrote:
> On Wed, Oct 21, 2009 at 7:13 PM, Cedric Staniewski <cedric at gmx.ca> wrote:
>> Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
>> ---
>>  scripts/makepkg.sh.in |    7 ++++++-
>>  1 files changed, 6 insertions(+), 1 deletions(-)
>>
>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>> index 40367ae..f6b87c2 100644
>> --- a/scripts/makepkg.sh.in
>> +++ b/scripts/makepkg.sh.in
>> @@ -336,7 +336,12 @@ download_file() {
>>                dlcmd="$dlcmd \"$url\""
>>        fi
>>
>> -       eval $dlcmd || return $?
>> +       eval $dlcmd
>> +       local ret=$?
>> +       if [ $ret -gt 0 ]; then
>> +               rm -f -- "$dlfile"
>> +               return $ret
>> +       fi
>>
>>        # rename the temporary download file to the final destination
>>        if [ "$dlfile" != "$file" ]; then
> 
> The purpose of the .part file is to allow resume.
> So I don't think we want to remove it.
> What was your intention, why are .part files a problem ?

Actually never thought about that since I did not experience a disrupted download so far. Therefore, the only .part files I saw were empty ones, because the source did not existed anymore or the url was just wrong.

Attached a new patch which should only remove the empty .part files. Thanks for the pointer.


>From c2a5b433f810995de5d7520287d5ea0c8209ecfa Mon Sep 17 00:00:00 2001
-- 8< --
From: Cedric Staniewski <cedric at gmx.ca>
Date: Wed, 21 Oct 2009 19:13:36 +0200
Subject: [PATCH] makepkg: remove empty .part files after a failed download

Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
---
 scripts/makepkg.sh.in |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 40367ae..3f1a054 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -336,7 +336,12 @@ download_file() {
 		dlcmd="$dlcmd \"$url\""
 	fi
 
-	eval $dlcmd || return $?
+	eval $dlcmd
+	local ret=$?
+	if [ $ret -gt 0 ]; then
+		[ ! -s "$dlfile" ] && rm -f -- "$dlfile"
+		return $ret
+	fi
 
 	# rename the temporary download file to the final destination
 	if [ "$dlfile" != "$file" ]; then
-- 
1.6.5.1



More information about the pacman-dev mailing list