From 317e7bf0b70903f585fdf286faa06d60fe0539f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Henrique=20Guard=C3=A3o=20Gandarez?= Date: Sun, 28 Jul 2024 22:17:21 -0300 Subject: [PATCH] Check if legacy offline queue file exists --- cmd/offlinesync/offlinesync.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/offlinesync/offlinesync.go b/cmd/offlinesync/offlinesync.go index 878834e5..6b9e1580 100644 --- a/cmd/offlinesync/offlinesync.go +++ b/cmd/offlinesync/offlinesync.go @@ -84,6 +84,10 @@ func syncOfflineActivityLegacy(v *viper.Viper, queueFilepath string) error { return nil } + if !fileExists(queueFilepath) { + return nil + } + paramOffline := params.LoadOfflineParams(v) paramAPI, err := params.LoadAPIParams(v) @@ -158,3 +162,9 @@ func SyncOfflineActivity(v *viper.Viper, queueFilepath string) error { return nil } + +// fileExists checks if a file or directory exist. +func fileExists(fp string) bool { + _, err := os.Stat(fp) + return err == nil || os.IsExist(err) +}