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 <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
9eb3695a3f
commit
c37a06fe1d
1 changed files with 5 additions and 5 deletions
|
@ -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
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue