Commit c37a06fe authored by Eli Schwartz's avatar Eli Schwartz Committed by Allan McRae
Browse files

libmakepkg: when checking for write permissions, handle pre-existing dirs



Simplifies the function a bit, but mostly, mkdir -p will never fail if
the directory exists, and therefore makepkg never checks to see if it is
actually writable. On the other hand, it's unnecessary to check if the
directory exists once we know mkdir -p succeeded...
Signed-off-by: Eli Schwartz's avatarEli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae's avatarAllan McRae <allan@archlinux.org>
parent 9eb3695a
......@@ -86,12 +86,12 @@ ensure_writable_dir() {
local dirtype="$1" dirpath="$2"
if ! mkdir -p "$dirpath" 2>/dev/null; then
if [[ -d $dirpath && ! -w $dirpath ]]; then
error "$(gettext "You do not have write permission for the directory \$%s (%s).")" "$dirtype" "$dirpath"
else
error "$(gettext "Failed to create the directory \$%s (%s).")" "$dirtype" "$dirpath"
fi
error "$(gettext "Failed to create the directory \$%s (%s).")" "$dirtype" "$dirpath"
return 1
elif [[ ! -w $dirpath ]]; then
error "$(gettext "You do not have write permission for the directory \$%s (%s).")" "$dirtype" "$dirpath"
return 1
fi
return 0
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment