diff options
author | Paul Okstad <pokstad@gitlab.com> | 2019-07-17 20:55:58 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2019-07-17 20:55:58 +0300 |
commit | 66f527787c1e1a2090f717236fcf7d9eb69bfc41 (patch) | |
tree | 2be79c4dffd0d14f03ad1bd557bf189b598ad00a /internal/cache | |
parent | 751f8949cdc948f587ab34bb3749199353ec213a (diff) |
Remove context from safe file
Diffstat (limited to 'internal/cache')
-rw-r--r-- | internal/cache/cachedb.go | 3 | ||||
-rw-r--r-- | internal/cache/keyer.go | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/internal/cache/cachedb.go b/internal/cache/cachedb.go index 9ba6deb25..787137233 100644 --- a/internal/cache/cachedb.go +++ b/internal/cache/cachedb.go @@ -83,10 +83,11 @@ func (sdb *StreamDB) PutStream(ctx context.Context, repo *gitalypb.Repository, r return err } - sf, err := safe.CreateFileWriter(ctx, reqPath) + sf, err := safe.CreateFileWriter(reqPath) if err != nil { return err } + defer sf.Close() n, err := io.Copy(sf, src) if err != nil { diff --git a/internal/cache/keyer.go b/internal/cache/keyer.go index c32dac1fe..da9b53b7d 100644 --- a/internal/cache/keyer.go +++ b/internal/cache/keyer.go @@ -59,7 +59,7 @@ type lease struct { // EndLease will end the lease by removing the pending lease file and updating // the key file with the current lease ID. func (l lease) EndLease(ctx context.Context) error { - _, err := updateLatest(ctx, l.repo) + _, err := updateLatest(l.repo) if err != nil { return err } @@ -74,7 +74,7 @@ func (l lease) EndLease(ctx context.Context) error { return nil } -func updateLatest(ctx context.Context, repo *gitalypb.Repository) (string, error) { +func updateLatest(repo *gitalypb.Repository) (string, error) { repoPath, err := helper.GetRepoPath(repo) if err != nil { return "", err @@ -85,10 +85,11 @@ func updateLatest(ctx context.Context, repo *gitalypb.Repository) (string, error return "", err } - latest, err := safe.CreateFileWriter(ctx, lPath) + latest, err := safe.CreateFileWriter(lPath) if err != nil { return "", err } + defer latest.Close() nextGenID := uuid.New().String() if nextGenID == "" { @@ -162,7 +163,7 @@ func (LeaseKeyer) KeyPath(ctx context.Context, repo *gitalypb.Repository, req pr return "", countErr(ErrPendingExists) } - genID, err := currentGenID(ctx, repo) + genID, err := currentGenID(repo) if err != nil { return "", err } @@ -242,7 +243,7 @@ func currentLeases(repo *gitalypb.Repository) ([]os.FileInfo, error) { return pendings, nil } -func currentGenID(ctx context.Context, repo *gitalypb.Repository) (string, error) { +func currentGenID(repo *gitalypb.Repository) (string, error) { repoPath, err := helper.GetRepoPath(repo) if err != nil { return "", err @@ -252,7 +253,7 @@ func currentGenID(ctx context.Context, repo *gitalypb.Repository) (string, error switch { case os.IsNotExist(err): // latest file doesn't exist, so create one - return updateLatest(ctx, repo) + return updateLatest(repo) case err == nil: return string(latestBytes), nil default: |