Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: Remove the "force" parameter from pkg_delete_files()
Mark Johnston committed 3 years ago
commit 2be9fd91afb0e3c6630483402b0cb914a74786c7
parent 4fd3822
3 files changed +11 -20
modified libpkg/pkg_add.c
@@ -1138,7 +1138,7 @@ pkg_add_cleanup_old(struct pkgdb *db, struct pkg *old, struct pkg *new, struct t
				}

				trigger_is_it_a_cleanup(t, f->path);
-
				pkg_delete_file(old, f, flags & PKG_DELETE_FORCE ? 1 : 0);
+
				pkg_delete_file(old, f);
			}
		}

modified libpkg/pkg_delete.c
@@ -99,8 +99,7 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags, struct triggers *t
		}
	}

-
	if ((ret = pkg_delete_files(pkg, flags & PKG_DELETE_FORCE ? 1 : 0, t))
-
            != EPKG_OK)
+
	if ((ret = pkg_delete_files(pkg, t)) != EPKG_OK)
		return (ret);

	if ((flags & (PKG_DELETE_NOSCRIPT | PKG_DELETE_UPGRADE)) == 0) {
@@ -268,7 +267,7 @@ pkg_effective_rmdir(struct pkgdb *db, struct pkg *pkg)
}

void
-
pkg_delete_file(struct pkg *pkg, struct pkg_file *file, unsigned force)
+
pkg_delete_file(struct pkg *pkg, struct pkg_file *file)
{
	const char *path;
	const char *prefix_rel;
@@ -309,12 +308,10 @@ pkg_delete_file(struct pkg *pkg, struct pkg_file *file, unsigned force)
#endif
	pkg_debug(1, "Deleting file: '%s'", path);
	if (unlinkat(pkg->rootfd, path, 0) == -1) {
-
		if (force < 2) {
-
			if (errno == ENOENT)
-
				pkg_emit_file_missing(pkg, file);
-
			else
-
				pkg_emit_errno("unlinkat", path);
-
		}
+
		if (errno == ENOENT)
+
			pkg_emit_file_missing(pkg, file);
+
		else
+
			pkg_emit_errno("unlinkat", path);
		return;
	}

@@ -324,11 +321,7 @@ pkg_delete_file(struct pkg *pkg, struct pkg_file *file, unsigned force)
}

int
-
pkg_delete_files(struct pkg *pkg, unsigned force, struct triggers *t)
-
	/* force: 0 ... be careful and vocal about it.
-
	 *        1 ... remove files without bothering about checksums.
-
	 *        2 ... like 1, but remain silent if removal fails.
-
	 */
+
pkg_delete_files(struct pkg *pkg, struct triggers *t)
{
	struct pkg_file	*file = NULL;

@@ -346,7 +339,7 @@ pkg_delete_files(struct pkg *pkg, unsigned force, struct triggers *t)
		append_touched_file(file->path);
		pkg_emit_progress_tick(cur_file++, nfiles);
		trigger_is_it_a_cleanup(t, file->path);
-
		pkg_delete_file(pkg, file, force);
+
		pkg_delete_file(pkg, file);
	}

	pkg_emit_progress_tick(nfiles, nfiles);
modified libpkg/private/pkg.h
@@ -611,8 +611,6 @@ int pkg_get_myarch_legacy(char *pkgarch, size_t sz);
 * Remove and unregister the package.
 * @param pkg An installed package to delete
 * @param db An opened pkgdb
-
 * @param force If set to one, the function will not fail if the package is
-
 * required by other packages.
 * @return An error code.
 */
int pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags, struct triggers *);
@@ -688,7 +686,7 @@ pkg_formats packing_format_from_string(const char *str);
const char* packing_format_to_string(pkg_formats format);
bool packing_is_valid_format(const char *str);

-
int pkg_delete_files(struct pkg *pkg, unsigned force, struct triggers *t);
+
int pkg_delete_files(struct pkg *pkg, struct triggers *t);
int pkg_delete_dirs(struct pkgdb *db, struct pkg *pkg, struct pkg *p);

/* pkgdb commands */
@@ -755,7 +753,7 @@ int pkg_add_from_remote(struct pkgdb *db, const char *path, unsigned flags,
    struct pkg_manifest_key *keys, const char *location, struct pkg *rp,
    struct triggers *);
void pkg_delete_dir(struct pkg *pkg, struct pkg_dir *dir);
-
void pkg_delete_file(struct pkg *pkg, struct pkg_file *file, unsigned force);
+
void pkg_delete_file(struct pkg *pkg, struct pkg_file *file);
int pkg_open_root_fd(struct pkg *pkg);
void pkg_add_dir_to_del(struct pkg *pkg, const char *file, const char *dir);
struct plist *plist_new(struct pkg *p, const char *stage);