Optimize backup: * Due to the way quilt uses backup-files, the backup file will never exist, so there is no point checking for this. * Don't attempt to create directories which already exist. * Use > instead of touch to create new files, it's faster. * Stop supporting option -t on backup, it's undocumented and quilt doesn't use it. * Drop unneeded quotes around constant.
Signed-off-by: Jean Delvare <[email protected]> Reviewed-by: Raphael Hertzog <[email protected]> --- quilt/scripts/backup-files.in | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) --- a/quilt/scripts/backup-files.in +++ b/quilt/scripts/backup-files.in @@ -60,19 +60,17 @@ ensure_nolinks() { backup() { local file="$1" local backup="${OPT_PREFIX}${file}" + local dir - if [ -e "$backup" ]; then - rm "$backup" - else - mkdir -p "$(dirname "$backup")" - fi + dir=$(dirname "$backup") + [ -d "$dir" ] || mkdir -p "$dir" if [ ! -e "$file" ]; then $ECHO "New file $file" - touch "$backup" + : > "$backup" else $ECHO "Copying $file" - if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = "1" ]; then + if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 1 ]; then cp -p "$file" "$backup" else ln "$file" "$backup" 2> /dev/null || cp -p "$file" "$backup" @@ -80,9 +78,6 @@ backup() { ensure_nolinks "$file" fi fi - if [ -n "$OPT_TOUCH" ]; then - touch "$backup" - fi fi } _______________________________________________ Quilt-dev mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/quilt-dev
