From 39f4cd4cfdbedcc0d84114bc15252a7a51fc197f Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 13 May 2023 16:08:59 +0000 Subject: [PATCH] fix: check if cache already exists --- distro/debian/debian.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/distro/debian/debian.go b/distro/debian/debian.go index d9b1c7d..56814a1 100644 --- a/distro/debian/debian.go +++ b/distro/debian/debian.go @@ -10,6 +10,7 @@ import ( "code.dumpstack.io/tools/out-of-tree/cache" "code.dumpstack.io/tools/out-of-tree/config" + "code.dumpstack.io/tools/out-of-tree/fs" ) type Release int @@ -131,9 +132,13 @@ func MatchImagePkg(km config.KernelMask) (pkgs []string, err error) { CachePath = config.File("debian.cache") log.Debug().Msgf("Use default kernels cache path: %s", CachePath) - err = cache.DownloadDebianCache(CachePath) - if err != nil { - log.Debug().Err(err).Msg("No remote cache, will take some time") + if !fs.PathExists(CachePath) { + log.Debug().Msgf("No cache, download") + err = cache.DownloadDebianCache(CachePath) + if err != nil { + log.Debug().Err(err).Msg( + "No remote cache, will take some time") + } } } else { log.Debug().Msgf("Debian kernels cache path: %s", CachePath)