Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
15c7e8de
Unverified
Commit
15c7e8de
authored
2 years ago
by
John Daly
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: Prevent uninitialized cacheProxy from being accessed in cleanup (#20975)
parent
c31eb5f1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/util/cache/package/index.spec.ts
+3
-0
3 additions, 0 deletions
lib/util/cache/package/index.spec.ts
lib/util/cache/package/index.ts
+2
-2
2 additions, 2 deletions
lib/util/cache/package/index.ts
with
5 additions
and
2 deletions
lib/util/cache/package/index.spec.ts
+
3
−
0
View file @
15c7e8de
...
@@ -7,6 +7,9 @@ describe('util/cache/package/index', () => {
...
@@ -7,6 +7,9 @@ describe('util/cache/package/index', () => {
it
(
'
returns undefined if not initialized
'
,
async
()
=>
{
it
(
'
returns undefined if not initialized
'
,
async
()
=>
{
expect
(
await
get
(
'
test
'
,
'
missing-key
'
)).
toBeUndefined
();
expect
(
await
get
(
'
test
'
,
'
missing-key
'
)).
toBeUndefined
();
expect
(
await
set
(
'
test
'
,
'
some-key
'
,
'
some-value
'
,
5
)).
toBeUndefined
();
expect
(
await
set
(
'
test
'
,
'
some-key
'
,
'
some-value
'
,
5
)).
toBeUndefined
();
expect
(
async
()
=>
{
await
cleanup
({});
}).
not
.
toThrow
();
});
});
it
(
'
sets and gets file
'
,
async
()
=>
{
it
(
'
sets and gets file
'
,
async
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
lib/util/cache/package/index.ts
+
2
−
2
View file @
15c7e8de
...
@@ -4,7 +4,7 @@ import * as fileCache from './file';
...
@@ -4,7 +4,7 @@ import * as fileCache from './file';
import
*
as
redisCache
from
'
./redis
'
;
import
*
as
redisCache
from
'
./redis
'
;
import
type
{
PackageCache
}
from
'
./types
'
;
import
type
{
PackageCache
}
from
'
./types
'
;
let
cacheProxy
:
PackageCache
;
let
cacheProxy
:
PackageCache
|
undefined
;
function
getGlobalKey
(
namespace
:
string
,
key
:
string
):
string
{
function
getGlobalKey
(
namespace
:
string
,
key
:
string
):
string
{
return
`global%%
${
namespace
}
%%
${
key
}
`
;
return
`global%%
${
namespace
}
%%
${
key
}
`
;
...
@@ -74,7 +74,7 @@ export async function cleanup(config: AllConfig): Promise<void> {
...
@@ -74,7 +74,7 @@ export async function cleanup(config: AllConfig): Promise<void> {
if
(
config
?.
redisUrl
)
{
if
(
config
?.
redisUrl
)
{
await
redisCache
.
end
();
await
redisCache
.
end
();
}
}
if
(
cacheProxy
.
cleanup
)
{
if
(
cacheProxy
?
.
cleanup
)
{
await
cacheProxy
.
cleanup
();
await
cacheProxy
.
cleanup
();
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment