mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-22 07:50:04 -05:00
staticupload: don't request empty invalidation (#1870)
If no files have been touched, do not initiate an invalidation.
This commit is contained in:
parent
06cd750345
commit
fa01569cc6
@ -125,6 +125,10 @@ func (c *Client) Flush(ctx context.Context) error {
|
||||
c.mux.Lock()
|
||||
defer c.mux.Unlock()
|
||||
|
||||
if len(c.dirtyKeys) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// invalidate all dirty keys that have not been invalidated yet
|
||||
invalidationID, err := c.invalidateCacheForKeys(ctx, c.dirtyKeys)
|
||||
if err != nil {
|
||||
@ -146,6 +150,11 @@ func (c *Client) invalidate(ctx context.Context, keys []string) error {
|
||||
c.dirtyKeys = append(c.dirtyKeys, keys...)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(keys) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// eagerly invalidate the CDN cache
|
||||
invalidationID, err := c.invalidateCacheForKeys(ctx, keys)
|
||||
if err != nil {
|
||||
|
@ -357,6 +357,7 @@ func TestFlush(t *testing.T) {
|
||||
wantCacheInvalidationErr: true,
|
||||
},
|
||||
"waiting for invalidation times out": {
|
||||
dirtyKeys: []string{"test-key-1"},
|
||||
invalidationIDs: []string{
|
||||
"test-invalidation-id-2",
|
||||
"test-invalidation-id-3",
|
||||
@ -364,6 +365,9 @@ func TestFlush(t *testing.T) {
|
||||
cacheInvalidationWaitTimeout: time.Microsecond,
|
||||
wantCacheInvalidationErr: true,
|
||||
},
|
||||
"no invalidations": {
|
||||
dirtyKeys: []string{},
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
|
Loading…
x
Reference in New Issue
Block a user