Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Simplify deleting directories
Baptiste Daroussin committed 14 years ago
commit 44de3ba59d38c622db44dd3f9f079147ad8ea458
parent 5a4d63a
2 files changed +15 -7
modified libpkg/pkg_delete.c
@@ -110,6 +110,18 @@ pkg_delete_files(struct pkg *pkg, int force)
				warn("%s", path);
			continue;
		}
+
		/* Directories */
+

+
		if (path[strlen(path) - 1] == '/') {
+
			/*
+
			 * currently do not warn on this because multiple
+
			 * packages can own the same directory
+
			 */
+
			rmdir(path);
+
			continue;
+
		}
+

+
		/* Regular files and links */
		/* check sha256 */
		do_remove = 1;
		if (pkg_file_sha256(files[i])[0] != '\0') {
@@ -127,13 +139,10 @@ pkg_delete_files(struct pkg *pkg, int force)
				}
			}
		}
+

		if (do_remove && unlink(pkg_file_path(files[i])) == -1) {
-
			if (is_dir(pkg_file_path(files[i]))) {
-
				rmdir(pkg_file_path(files[i]));
-
			} else {
-
				warn("unlink(%s)", pkg_file_path(files[i]));
-
				continue;
-
			}
+
			warn("unlink(%s)", pkg_file_path(files[i]));
+
			continue;
		}
	}

modified libpkg/pkgdb.c
@@ -716,7 +716,6 @@ pkgdb_loadfiles(struct pkgdb *db, struct pkg *pkg)
		return (ERROR_SQLITE(db->sqlite));
	}

-
	printf("ici\n");
	if (sqlite3_prepare_v2(db->sqlite, sqldir, -1, &stmt, NULL) != SQLITE_OK)
		return (ERROR_SQLITE(db->sqlite));