Skip to content

Commit

Permalink
Use the temp. prefix for temporary directories (#46)
Browse files Browse the repository at this point in the history
This change helps narrow down the list of false positives when copying
directories to s3.
  • Loading branch information
lhchavez authored Nov 11, 2022
1 parent 8ad4cc0 commit 893c2fa
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ziphandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"io"
"io/fs"
"io/ioutil"
"math/big"
"mime/multipart"
"net/http"
Expand Down Expand Up @@ -384,7 +383,7 @@ func CreatePackfile(
}
defer odb.Free()

looseObjectsDir, err := ioutil.TempDir("", fmt.Sprintf("loose_objects_%s", path.Base(repo.Path())))
looseObjectsDir, err := os.MkdirTemp("", fmt.Sprintf("loose_objects_%s", path.Base(repo.Path())))
if err != nil {
return nil, errors.Wrap(
err,
Expand Down Expand Up @@ -538,7 +537,7 @@ func CreatePackfile(
}

if !strings.Contains(filename, "/") {
blobContents, err := ioutil.ReadAll(r)
blobContents, err := io.ReadAll(r)
if err != nil {
return nil, base.ErrorWithCategory(
ErrInternalGit,
Expand Down Expand Up @@ -1185,7 +1184,7 @@ func PushZip(
When: time.Now(),
}

packfile, err := ioutil.TempFile("", "gitserver-packfile")
packfile, err := os.CreateTemp("", "gitserver-packfile")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1447,7 +1446,7 @@ func (h *zipUploadHandler) handleGitUploadZip(
return
}

tempfile, err := ioutil.TempFile("", "gitserver-zip")
tempfile, err := os.CreateTemp("", "gitserver-zip")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
Expand Down Expand Up @@ -1496,7 +1495,7 @@ func (h *zipUploadHandler) handleGitUploadZip(
openRepoSegment := txn.StartSegment("open repository")
commitCallback := func() error { return nil }
if requestContext.Request.Create {
dir, err := ioutil.TempDir(filepath.Dir(repositoryPath), "repository")
dir, err := os.MkdirTemp(filepath.Dir(repositoryPath), "temp.repository.")
if err != nil {
log.Error(
"Failed to create temporary directory",
Expand Down

0 comments on commit 893c2fa

Please sign in to comment.