Skip to content

Commit 66f8ef1

Browse files
authored
trying file.copy instead of os.rename (#4992)
trying file.copy instead of os.rename (#4992)
2 parents f11ba33 + 52d3f70 commit 66f8ef1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

toolkit/tools/scheduler/schedulerutils/buildworker.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"sync"
1313
"time"
1414

15+
"github.com/microsoft/CBL-Mariner/toolkit/tools/internal/file"
1516
"github.com/microsoft/CBL-Mariner/toolkit/tools/internal/logger"
1617
"github.com/microsoft/CBL-Mariner/toolkit/tools/internal/pkggraph"
1718
"github.com/microsoft/CBL-Mariner/toolkit/tools/internal/retry"
@@ -191,14 +192,14 @@ func getBuildDependencies(node *pkggraph.PkgNode, pkgGraph *pkggraph.PkgGraph, g
191192

192193
// parseCheckSection reads the package build log file to determine if the %check section passed or not
193194
func parseCheckSection(logFile string) (err error) {
194-
file, err := os.Open(logFile)
195+
logFileObject, err := os.Open(logFile)
195196
// If we can't open the log file, that's a build error.
196197
if err != nil {
197198
logger.Log.Errorf("Failed to open log file '%s' while checking package test results. Error: %v", logFile, err)
198199
return
199200
}
200-
defer file.Close()
201-
for scanner := bufio.NewScanner(file); scanner.Scan(); {
201+
defer logFileObject.Close()
202+
for scanner := bufio.NewScanner(logFileObject); scanner.Scan(); {
202203
currLine := scanner.Text()
203204
// Anything besides 0 is a failed test
204205
if strings.Contains(currLine, "CHECK DONE") {
@@ -207,7 +208,7 @@ func parseCheckSection(logFile string) (err error) {
207208
}
208209
failedLogFile := strings.TrimSuffix(logFile, ".log")
209210
failedLogFile = fmt.Sprintf("%s-FAILED_TEST-%d.log", failedLogFile, time.Now().UnixMilli())
210-
err = os.Rename(logFile, failedLogFile)
211+
err = file.Copy(logFile, failedLogFile)
211212
if err != nil {
212213
logger.Log.Errorf("Log file rename failed. Error: %v", err)
213214
return

0 commit comments

Comments
 (0)