File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,20 @@ function set-unless($name,$value){
1313" $rv " .trim()
1414}
1515
16+ function getUrlDate ($url ){
17+ try {
18+ $LAST_MODIFIED_HEADER = ((Invoke-WebRequest - URI $url - Method Head).headers[' Last-modified' ])
19+ } catch {
20+ " Thursday, January 1, 1970"
21+ }
22+ if ($LAST_MODIFIED_HEADER ){
23+ " $LAST_MODIFIED_HEADER "
24+ }else {
25+ (Get-Date )
26+ }
27+ }
28+
29+
1630if ( $env: CC_INSTALLER.Length -eq 0 ) {
1731 $CC_VERSION = set-unless $env: CC_VERSION " 10.3-milestone"
1832 $CC_INSTALLER = " cc-def-$CC_VERSION -w64.exe"
@@ -28,9 +42,10 @@ if(! (test-path "$env:USERPROFILE\Downloads")){
2842}
2943$file = " $env: USERPROFILE \Downloads\$CC_INSTALLER "
3044$HTTP_CODE = 0
31- if (test-path $file ){
32- " Found local copy of $file "
33- " Download skipped"
45+
46+ $LAST_MODIFIED_URL_DATE = getUrlDate " $URL /$CC_INSTALLER "
47+ if ( (test-path $file ) -and ! (Test-Path $file - OlderThan $LAST_MODIFIED_URL_DATE )){
48+ " Found newer file $file locally, skipping download"
3449 $EXIT_CODE = 0
3550 $HTTP_CODE = 200
3651} else {
@@ -105,4 +120,4 @@ if ( $HTTP_CODE -eq 200 ){
105120 # "set PATH=$env:PATH;$CC_CLI_HOME\bin:$ANTCC_HOME\bin:$ANT_HOME\bin"
106121}else {
107122 die " Download failed with http code: $HTTP_CODE " 1
108- }
123+ }
You can’t perform that action at this time.
0 commit comments