From 3087efb21a81f9b48349da15e3021ba07bc646ce Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 12:37:32 -0400 Subject: [PATCH] fix: surface errors when compressing files (#13491) (#13494) Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: schakrad <58915923+schakrad@users.noreply.github.com> --- util/cmp/stream.go | 6 +++--- util/manifeststream/stream.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/util/cmp/stream.go b/util/cmp/stream.go index 2b4f798dce49..768d41dbb4f4 100644 --- a/util/cmp/stream.go +++ b/util/cmp/stream.go @@ -109,12 +109,12 @@ func SendRepoStream(ctx context.Context, appPath, repoPath string, sender Stream func GetCompressedRepoAndMetadata(repoPath string, appPath string, env []string, excludedGlobs []string, opt *senderOption) (*os.File, *pluginclient.AppStreamRequest, error) { // compress all files in appPath in tgz tgz, filesWritten, checksum, err := tgzstream.CompressFiles(repoPath, nil, excludedGlobs) - if filesWritten == 0 { - return nil, nil, fmt.Errorf("no files to send") - } if err != nil { return nil, nil, fmt.Errorf("error compressing repo files: %w", err) } + if filesWritten == 0 { + return nil, nil, fmt.Errorf("no files to send") + } if opt != nil && opt.tarDoneChan != nil { opt.tarDoneChan <- true close(opt.tarDoneChan) diff --git a/util/manifeststream/stream.go b/util/manifeststream/stream.go index 729e564e7950..34b552fcca58 100644 --- a/util/manifeststream/stream.go +++ b/util/manifeststream/stream.go @@ -40,12 +40,12 @@ type RepoStreamReceiver interface { // SendApplicationManifestQueryWithFiles compresses a folder and sends it over the stream func SendApplicationManifestQueryWithFiles(ctx context.Context, stream ApplicationStreamSender, appName string, appNs string, dir string, inclusions []string) error { f, filesWritten, checksum, err := tgzstream.CompressFiles(dir, inclusions, nil) - if filesWritten == 0 { - return fmt.Errorf("no files to send") - } if err != nil { return fmt.Errorf("failed to compress files: %w", err) } + if filesWritten == 0 { + return fmt.Errorf("no files to send") + } err = stream.Send(&applicationpkg.ApplicationManifestQueryWithFilesWrapper{ Part: &applicationpkg.ApplicationManifestQueryWithFilesWrapper_Query{