Skip to content

Commit b524183

Browse files
committed
Do not check and warn of stale candidates cache.
1 parent 71c9490 commit b524183

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/main/bash/sdkman-cache.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,14 @@
1818

1919
function ___sdkman_check_candidates_cache() {
2020
local candidates_cache="$1"
21-
if [[ -f "$candidates_cache" && -n "$(< "$candidates_cache")" && -n "$(find "$candidates_cache" -mmin +$((24 * 60 * 30)))" ]]; then
22-
__sdkman_echo_yellow 'We periodically need to update the local cache. Please run:'
23-
echo ''
24-
__sdkman_echo_no_colour ' $ sdk update'
25-
echo ''
26-
return 0
27-
elif [[ -f "$candidates_cache" && -z "$(< "$candidates_cache")" ]]; then
21+
if [[ -f "$candidates_cache" && -z "$(< "$candidates_cache")" ]]; then
2822
__sdkman_echo_red 'WARNING: Cache is corrupt. SDKMAN cannot be used until updated.'
2923
echo ''
3024
__sdkman_echo_no_colour ' $ sdk update'
3125
echo ''
3226
return 1
3327
else
34-
__sdkman_echo_debug "No update at this time. Using existing cache: $SDKMAN_CANDIDATES_CSV"
28+
__sdkman_echo_debug "Using existing cache: $SDKMAN_CANDIDATES_CSV"
3529
return 0
3630
fi
3731
}

src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification {
3939
!bash.output.contains("SDKMAN 5.0.0")
4040
}
4141

42-
void "should issue a warning if cache is older than a month"() {
42+
void "should NOT issue a warning if cache is older than a month"() {
4343
given:
4444
bash = sdkmanBashEnvBuilder
4545
.withCandidates(['groovy'])
@@ -56,11 +56,11 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification {
5656
bash.execute("sdk help")
5757

5858
then:
59-
bash.output.contains('We periodically need to update the local cache.')
60-
bash.output.contains('$ sdk update')
59+
!bash.output.contains('We periodically need to update the local cache.')
60+
!bash.output.contains('$ sdk update')
6161
}
6262

63-
void "should log a success message in debug mode when no update needed"() {
63+
void "should log a success message if cache exists"() {
6464
given:
6565
bash = sdkmanBashEnvBuilder
6666
.withCandidates(['groovy'])
@@ -74,7 +74,7 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification {
7474
bash.execute("sdk help")
7575

7676
then:
77-
bash.output.contains('No update at this time. Using existing cache')
77+
bash.output.contains('Using existing cache')
7878
}
7979

8080
void "should bypass cache check if update command issued"() {

0 commit comments

Comments
 (0)