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){
13
13
" $rv " .trim()
14
14
}
15
15
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
+
16
30
if ( $env: CC_INSTALLER.Length -eq 0 ) {
17
31
$CC_VERSION = set-unless $env: CC_VERSION " 10.3-milestone"
18
32
$CC_INSTALLER = " cc-def-$CC_VERSION -w64.exe"
@@ -28,9 +42,10 @@ if(! (test-path "$env:USERPROFILE\Downloads")){
28
42
}
29
43
$file = " $env: USERPROFILE \Downloads\$CC_INSTALLER "
30
44
$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"
34
49
$EXIT_CODE = 0
35
50
$HTTP_CODE = 200
36
51
} else {
@@ -105,4 +120,4 @@ if ( $HTTP_CODE -eq 200 ){
105
120
# "set PATH=$env:PATH;$CC_CLI_HOME\bin:$ANTCC_HOME\bin:$ANT_HOME\bin"
106
121
}else {
107
122
die " Download failed with http code: $HTTP_CODE " 1
108
- }
123
+ }
You can’t perform that action at this time.
0 commit comments