[pacman-dev] [PATCH] repo-remove: remove deltas file is it becomes empty
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- scripts/repo-add.sh.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 043a0b8..147da69 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -176,6 +176,11 @@ db_remove_delta() { if grep -q "$filename" $deltas; then sed -i.backup "/$filename/d" $deltas && rm -f $deltas.backup msg2 "$(gettext "Removing existing entry '%s'...")" "$filename" + # empty deltas file contains only "%DELTAS%" + if [[ $(wc -l "$deltas" | cut -d\ -f1) = 1 ]]; then + msg2 "$(gettext "Removing empty deltas file ...")" + rm $deltas + fi return 0 fi -- 1.7.9.6
On Fri, Apr 06, 2012 at 06:18:45PM +0200, Florian Pritz wrote:
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- scripts/repo-add.sh.in | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 043a0b8..147da69 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -176,6 +176,11 @@ db_remove_delta() { if grep -q "$filename" $deltas; then sed -i.backup "/$filename/d" $deltas && rm -f $deltas.backup msg2 "$(gettext "Removing existing entry '%s'...")" "$filename" + # empty deltas file contains only "%DELTAS%" + if [[ $(wc -l "$deltas" | cut -d\ -f1) = 1 ]]; then
eww. piping the file to wc avoids the need for this. (( $(wc -l < "$deltas") == 1 ))
+ msg2 "$(gettext "Removing empty deltas file ...")" + rm $deltas + fi return 0 fi
-- 1.7.9.6
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- scripts/repo-add.sh.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 043a0b8..1febfae 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -176,6 +176,11 @@ db_remove_delta() { if grep -q "$filename" $deltas; then sed -i.backup "/$filename/d" $deltas && rm -f $deltas.backup msg2 "$(gettext "Removing existing entry '%s'...")" "$filename" + # empty deltas file contains only "%DELTAS%" + if (( $(wc -l < "$deltas") == 1 )); then + msg2 "$(gettext "Removing empty deltas file ...")" + rm $deltas + fi return 0 fi -- 1.7.9.6
On 07/04/12 02:22, Florian Pritz wrote:
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- scripts/repo-add.sh.in | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 043a0b8..1febfae 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -176,6 +176,11 @@ db_remove_delta() { if grep -q "$filename" $deltas; then sed -i.backup "/$filename/d" $deltas && rm -f $deltas.backup msg2 "$(gettext "Removing existing entry '%s'...")" "$filename" + # empty deltas file contains only "%DELTAS%" + if (( $(wc -l < "$deltas") == 1 )); then + msg2 "$(gettext "Removing empty deltas file ...")" + rm $deltas
I know this is rampant in the repo-add code, but please add quotes around the file path. TMPDIR="/path/with/some spaces" would seriously break repo-add... Feel free to fix the rest of missing quotes too.
+ fi return 0 fi
participants (3)
-
Allan McRae
-
Dave Reisner
-
Florian Pritz