From 2b39357443100188ceee0a68408416d166037247 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 14 Jun 2021 05:06:52 +0200 Subject: [PATCH] Fixed sanitize errors. (#15240) Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH Co-authored-by: techknowlogick --- services/mirror/mirror.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go index 9e2dde85f..839d692f9 100644 --- a/services/mirror/mirror.go +++ b/services/mirror/mirror.go @@ -230,18 +230,14 @@ func runSync(ctx context.Context, m *models.Mirror) ([]*mirrorSyncResult, bool) stderrMessage, sanitizeErr := sanitizeOutput(stderr, repoPath) if sanitizeErr != nil { log.Error("sanitizeOutput failed on stderr: %v", sanitizeErr) - log.Error("Failed to update mirror repository %v:\nStdout: %s\nStderr: %s\nErr: %v", m.Repo, stdout, stderr, err) - return nil, false } - stdoutMessage, err := sanitizeOutput(stdout, repoPath) - if err != nil { + stdoutMessage, sanitizeErr := sanitizeOutput(stdout, repoPath) + if sanitizeErr != nil { log.Error("sanitizeOutput failed: %v", sanitizeErr) - log.Error("Failed to update mirror repository %v:\nStdout: %s\nStderr: %s\nErr: %v", m.Repo, stdout, stderrMessage, err) - return nil, false } log.Error("Failed to update mirror repository %v:\nStdout: %s\nStderr: %s\nErr: %v", m.Repo, stdoutMessage, stderrMessage, err) - desc := fmt.Sprintf("Failed to update mirror repository '%s': %s", repoPath, stderrMessage) + desc := fmt.Sprintf("Failed to update mirror repository '%s': %s", m.Repo.FullName(), stderrMessage) if err = models.CreateRepositoryNotice(desc); err != nil { log.Error("CreateRepositoryNotice: %v", err) } @@ -286,21 +282,17 @@ func runSync(ctx context.Context, m *models.Mirror) ([]*mirrorSyncResult, bool) stderr := stderrBuilder.String() // sanitize the output, since it may contain the remote address, which may // contain a password - stderrMessage, sanitizeErr := sanitizeOutput(stderr, repoPath) + stderrMessage, sanitizeErr := sanitizeOutput(stderr, wikiPath) if sanitizeErr != nil { log.Error("sanitizeOutput failed on stderr: %v", sanitizeErr) - log.Error("Failed to update mirror repository wiki %v:\nStdout: %s\nStderr: %s\nErr: %v", m.Repo, stdout, stderr, err) - return nil, false } - stdoutMessage, err := sanitizeOutput(stdout, repoPath) - if err != nil { + stdoutMessage, sanitizeErr := sanitizeOutput(stdout, wikiPath) + if sanitizeErr != nil { log.Error("sanitizeOutput failed: %v", sanitizeErr) - log.Error("Failed to update mirror repository wiki %v:\nStdout: %s\nStderr: %s\nErr: %v", m.Repo, stdout, stderrMessage, err) - return nil, false } log.Error("Failed to update mirror repository wiki %v:\nStdout: %s\nStderr: %s\nErr: %v", m.Repo, stdoutMessage, stderrMessage, err) - desc := fmt.Sprintf("Failed to update mirror repository wiki '%s': %s", wikiPath, stderrMessage) + desc := fmt.Sprintf("Failed to update mirror repository wiki '%s': %s", m.Repo.FullName(), stderrMessage) if err = models.CreateRepositoryNotice(desc); err != nil { log.Error("CreateRepositoryNotice: %v", err) }