From 658ed7cef6e7e2d6aaf6f74d22056622094a1868 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Wed, 28 Apr 2021 14:03:54 +0100 Subject: [PATCH] pv-runtime: GC all deployments if operating from an unpacked directory If we are operating from ./scout_platform_x.y.z, self->id will be NULL. Instead of matching on the names of directories, we can just check whether the deployment we are going to use is the same file (device and inode number) as the old deployment we are considering deleting. Signed-off-by: Simon McVittie <smcv@collabora.com> --- pressure-vessel/runtime.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 8505c1c74..499cf69a2 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -820,17 +820,10 @@ pv_runtime_garbage_collect (PvRuntime *self, if (g_str_has_prefix (dent->d_name, "deploy-")) { - /* Don't GC old deployments unless we know which one is current - * and therefore should not be deleted */ - if (self->id == NULL) - { - g_debug ("Ignoring %s/deploy-*: current ID not known", - self->variable_dir); - continue; - } - - /* Don't GC the current deployment */ - if (strcmp (dent->d_name + strlen ("deploy-"), self->id) == 0) + if (_srt_fstatat_is_same_file (self->variable_dir_fd, + dent->d_name, + AT_FDCWD, + self->deployment)) { g_debug ("Ignoring %s/%s: is the current version", self->variable_dir, dent->d_name); -- GitLab