Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
do not extract files identical to what is already present
Baptiste Daroussin committed 11 years ago
commit 7bde22fba93a8898afff22bcee81005b11dbea53
parent de25918
1 file changed +12 -0
modified libpkg/pkg_add.c
@@ -177,6 +177,18 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
		strlcpy(rpath, pathname, sizeof(rpath));

		if (lstat(rpath, &st) != -1 && !S_ISDIR(st.st_mode)) {
+
			/* check is the old version is the same as the new version */
+
			if (S_ISREG(st.st_mode) && st.st_size == archive_entry_size(ae)) {
+
				char localsum[SHA256_DIGEST_LENGTH + 2 + 1];
+
				if (sha256_file(rpath, localsum) == EPKG_OK) {
+
					HASH_FIND_STR(pkg->files, path, rf);
+
					if (strcmp(localsum, rf->sum) == 0) {
+
						pkg_debug(2, "Do not extract identical file");
+
						pkg_emit_progress_tick(cur_file++, nfiles);
+
						continue;
+
					}
+
				}
+
			}
			/*
			 * We have an existing file on the path, so handle it
			 */