unpack: make sure to remove only on-disk files if file type does not match.

Added another ATF test-case to make sure it works properly.
This commit is contained in:
Juan RP
2013-11-09 08:59:02 +01:00
parent efdb0eb5a4
commit 6d9bb47fba
2 changed files with 49 additions and 2 deletions

View File

@@ -371,10 +371,11 @@ unpack_archive(struct xbps_handle *xhp,
if (lstat(entry_pname, &st) == 0)
file_exists = true;
/*
* If file to be extracted does not match the mode_t of
* If file to be extracted does not match the file type of
* file currently stored on disk, remove file on disk.
*/
if (file_exists && (entry_statp->st_mode != st.st_mode))
if (file_exists &&
((entry_statp->st_mode & S_IFMT) != (st.st_mode & S_IFMT)))
remove(entry_pname);
if (!force && (entry_type == AE_IFREG)) {