Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.

Commit a5119f8

Browse files
authored
Merge pull request #647 from marccampbell/remove-watch-dir
Remove watch dir after checking content sha
2 parents 47da209 + 67e6e98 commit a5119f8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/specs/interface.go

+7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ func (r *Resolver) ReadContentSHAForWatch(ctx context.Context, upstream string)
8888
}
8989
debug.Log("event", "apptype.inspect", "type", appType, "localPath", localPath)
9090

91+
defer func() {
92+
if err := r.FS.RemoveAll(localPath); err != nil {
93+
level.Error(r.Logger).Log("event", "remove watch dir", "err", err)
94+
}
95+
}()
96+
9197
// this switch block is kinda duped from above, and we ought to centralize parts of this,
9298
// but in this case we only want to read the metadata without persisting anything to state,
9399
// and there doesn't seem to be a good way to evolve that abstraction cleanly from what we have, at least not just yet
@@ -98,6 +104,7 @@ func (r *Resolver) ReadContentSHAForWatch(ctx context.Context, upstream string)
98104
if err != nil {
99105
return "", errors.Wrapf(err, "resolve metadata and content sha for %s", upstream)
100106
}
107+
101108
return metadata.ContentSHA, nil
102109

103110
case "k8s":

pkg/specs/interface_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ func TestResolver_ReadContentSHAForWatch(t *testing.T) {
280280
appTypeInspector: inspector,
281281
AppResolver: resolver,
282282
shaSummer: test.shaSummer,
283+
FS: afero.Afero{Fs: afero.NewMemMapFs()},
283284
}
284285

285286
sha, err := r.ReadContentSHAForWatch(ctx, test.upstream)

0 commit comments

Comments
 (0)