Improve flush by making it more resilient.

This commit is contained in:
Marco Vermeulen
2013-07-12 13:58:42 +01:00
parent 32c9490b92
commit 97b2a10ff1
3 changed files with 27 additions and 19 deletions

View File

@@ -31,17 +31,24 @@ function __gvmtool_cleanup_folder {
unset GVM_CLEANUP_COUNT
}
function __gvmtool_flush {
QUALIFIER="$1"
case "$QUALIFIER" in
candidates)
rm "$GVM_DIR/var/candidates"
echo "Candidates have been flushed."
if [[ -f "${GVM_DIR}/var/candidates" ]]; then
rm "${GVM_DIR}/var/candidates"
echo "Candidates have been flushed."
else
echo "No candidate list found so not flushed."
fi
;;
broadcast)
rm "$GVM_DIR/var/broadcast"
echo "Broadcast has been flushed."
if [[ -f "${GVM_DIR}/var/broadcast" ]]; then
rm "${GVM_DIR}/var/broadcast"
echo "Broadcast has been flushed."
else
echo "No prior broadcast found so not flushed."
fi
;;
archives)
__gvmtool_cleanup_folder "archives"
@@ -56,5 +63,4 @@ function __gvmtool_flush {
echo "Stop! Please specify what you want to flush."
;;
esac
}

View File

@@ -7,34 +7,36 @@ Feature: Flush
When I enter "gvm flush"
Then I see "Stop! Please specify what you want to flush."
Scenario: Clear out my Candidate List
Scenario: Clear out the Candidate List
Given the candidate "grails" is known locally
When I enter "gvm flush candidates"
Then no candidates are know locally
And I see "Candidates have been flushed."
Scenario: Clean up my current broadcast
Scenario: Clear out an uninitialised Candidate List
Given I enter "gvm flush candidates"
When I enter "gvm flush candidates"
Then I see "No candidate list found so not flushed."
Scenario: Clean up the current Broadcast
Given a prior Broadcast "This is an old broadcast" was issued
When I enter "gvm flush broadcast"
Then no broadcast message can be found
And I see "Broadcast has been flushed."
Scenario: Clear out my cached Archives
Scenario: Clean up an uninitialised Broadcast
Given I enter "gvm flush broadcast"
When I enter "gvm flush broadcast"
Then I see "No prior broadcast found so not flushed."
Scenario: Clear out the cached Archives
Given the archive "grails-1.3.9.zip" has been cached
When I enter "gvm flush archives"
Then no archives are cached
And I see "1 archive(s) flushed, freeing 4.0K"
Scenario: Clear out my temporary space
Scenario: Clear out the temporary space
Given the file "res-1.2.0.zip" in temporary storage
When I enter "gvm flush temp"
Then no "res-1.2.0.zip" file is present in temporary storage
And I see "1 archive(s) flushed, freeing 4.0K"
Scenario: Clear out my temporary space
Given the file "res-1.2.0.zip" in temporary storage
When I enter "gvm flush tmp"
Then no "res-1.2.0.zip" file is present in temporary storage
And I see "1 archive(s) flushed, freeing 4.0K"

View File

@@ -23,4 +23,4 @@ Given(~'^the file "([^"]*)" in temporary storage$') { String fileName ->
}
Then(~'^no "([^"]*)" file is present in temporary storage$') { String fileName ->
assert ! new File(tmpDir, fileName).exists()
}
}