Avoid check-then-act pattern in clear_cache

This commit is contained in:
Jack Nagel 2014-12-23 01:04:44 -05:00
parent 957ef9b6b9
commit 32bf6d9937

View File

@ -28,6 +28,7 @@ class AbstractDownloadStrategy
# Remove {#cached_location} and any other files associated with the resource
# from the cache.
def clear_cache
rm_rf(cached_location)
end
def expand_safe_system_args args
@ -127,10 +128,6 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
@clone
end
def clear_cache
cached_location.rmtree if cached_location.exist?
end
def head?
version.head?
end
@ -240,7 +237,8 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
end
def clear_cache
[cached_location, temporary_path].each { |f| f.unlink if f.exist? }
super
rm_rf(temporary_path)
end
private