Merge pull request #3501 from dreamcat4/fix/win-modules-strict-mode-fixes
Fix/win modules strict mode fixes
This commit is contained in:
commit
c6f5475afe
2 changed files with 34 additions and 10 deletions
|
@ -105,7 +105,7 @@ Else {
|
|||
Fail-Json $result "Error when requesting Last-Modified date from $url $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
If ((Get-Date -Date $webLastMod ) -lt $fileLastMod) {
|
||||
If (($webLastMod) -and ((Get-Date -Date $webLastMod ) -lt $fileLastMod)) {
|
||||
$result.changed = $false
|
||||
} Else {
|
||||
Download-File -result $result -url $url -dest $dest -username $username -password $password -proxy_url $proxy_url -proxy_username $proxy_username -proxy_password $proxy_password
|
||||
|
|
|
@ -21,7 +21,10 @@ $params = Parse-Args $args $true;
|
|||
|
||||
function Date_To_Timestamp($start_date, $end_date)
|
||||
{
|
||||
Write-Output (New-TimeSpan -Start $start_date -End $end_date).TotalSeconds
|
||||
If($start_date -and $end_date)
|
||||
{
|
||||
Write-Output (New-TimeSpan -Start $start_date -End $end_date).TotalSeconds
|
||||
}
|
||||
}
|
||||
|
||||
$path = Get-Attr $params "path" $FALSE;
|
||||
|
@ -42,23 +45,44 @@ $result = New-Object psobject @{
|
|||
If (Test-Path $path)
|
||||
{
|
||||
Set-Attr $result.stat "exists" $TRUE;
|
||||
|
||||
$info = Get-Item $path;
|
||||
$iscontainer = Get-Attr $info "PSIsContainer" $null;
|
||||
$length = Get-Attr $info "Length" $null;
|
||||
$extension = Get-Attr $info "Extension" $null;
|
||||
$attributes = Get-Attr $info "Attributes" "";
|
||||
If ($info)
|
||||
{
|
||||
$accesscontrol = $info.GetAccessControl();
|
||||
}
|
||||
Else
|
||||
{
|
||||
$accesscontrol = $null;
|
||||
}
|
||||
$owner = Get-Attr $accesscontrol "Owner" $null;
|
||||
$creationtime = Get-Attr $info "CreationTime" $null;
|
||||
$lastaccesstime = Get-Attr $info "LastAccessTime" $null;
|
||||
$lastwritetime = Get-Attr $info "LastWriteTime" $null;
|
||||
|
||||
|
||||
$epoch_date = Get-Date -Date "01/01/1970"
|
||||
If ($info.PSIsContainer)
|
||||
If ($iscontainer)
|
||||
{
|
||||
Set-Attr $result.stat "isdir" $TRUE;
|
||||
}
|
||||
Else
|
||||
{
|
||||
Set-Attr $result.stat "isdir" $FALSE;
|
||||
Set-Attr $result.stat "size" $info.Length;
|
||||
Set-Attr $result.stat "size" $length;
|
||||
}
|
||||
Set-Attr $result.stat "extension" $info.Extension;
|
||||
Set-Attr $result.stat "attributes" $info.Attributes.ToString();
|
||||
Set-Attr $result.stat "owner" $info.GetAccessControl().Owner;
|
||||
Set-Attr $result.stat "creationtime" (Date_To_Timestamp $epoch_date $info.CreationTime);
|
||||
Set-Attr $result.stat "lastaccesstime" (Date_To_Timestamp $epoch_date $info.LastAccessTime);
|
||||
Set-Attr $result.stat "lastwritetime" (Date_To_Timestamp $epoch_date $info.LastWriteTime);
|
||||
Set-Attr $result.stat "extension" $extension;
|
||||
Set-Attr $result.stat "attributes" $attributes.ToString();
|
||||
# Set-Attr $result.stat "owner" $getaccesscontrol.Owner;
|
||||
# Set-Attr $result.stat "owner" $info.GetAccessControl().Owner;
|
||||
Set-Attr $result.stat "owner" $owner;
|
||||
Set-Attr $result.stat "creationtime" (Date_To_Timestamp $epoch_date $creationtime);
|
||||
Set-Attr $result.stat "lastaccesstime" (Date_To_Timestamp $epoch_date $lastaccesstime);
|
||||
Set-Attr $result.stat "lastwritetime" (Date_To_Timestamp $epoch_date $lastwritetime);
|
||||
}
|
||||
Else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue