From 3c0edd40c8d4ce5d9d1c945af702fbca46ac5a1f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 21 Dec 2013 12:03:38 +0100 Subject: [PATCH] lib/package_unpack.c: only create rootdir if it doesn't exist once. --- lib/package_unpack.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/package_unpack.c b/lib/package_unpack.c index da86874f..fcb9f142 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -203,24 +203,6 @@ unpack_archive(struct xbps_handle *xhp, if (xhp->flags & XBPS_FLAG_FORCE_UNPACK) force = true; - if (access(xhp->rootdir, R_OK) == -1) { - if (errno != ENOENT) { - rv = errno; - goto out; - } - if (xbps_mkpath(xhp->rootdir, 0750) == -1) { - rv = errno; - goto out; - } - } - if (chdir(xhp->rootdir) == -1) { - xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, - errno, pkgver, - "%s: [unpack] failed to chdir to rootdir `%s': %s", - pkgver, xhp->rootdir, strerror(errno)); - rv = errno; - goto out; - } if (strcmp(transact, "update") == 0) update = true; /* @@ -696,6 +678,24 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod) /* * Extract archive files. */ + if (access(xhp->rootdir, R_OK) == -1) { + if (errno != ENOENT) { + rv = errno; + goto out; + } + if (xbps_mkpath(xhp->rootdir, 0750) == -1) { + rv = errno; + goto out; + } + } + if (chdir(xhp->rootdir) == -1) { + xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, + errno, pkgver, + "%s: [unpack] failed to chdir to rootdir `%s': %s", + pkgver, xhp->rootdir, strerror(errno)); + rv = errno; + goto out; + } if ((rv = unpack_archive(xhp, pkg_repod, pkgver, bpkg, ar)) != 0) { xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, pkgver,