Sha256: d31a1a6f97a79ac304ac9bf372f10ca076ddb0314b2e6a140f8471eb9426d782

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

$hash_file = <%= hash_file %>

Function Cleanup($disposable) {
  if (($disposable -ne $null) -and ($disposable.GetType().GetMethod("Dispose") -ne $null)) {
    $disposable.Dispose()
  }
}

Function Check-Files($h) {
  return $h.GetEnumerator() | ForEach-Object {
    $dst = Unresolve-Path $_.Value.target
    $dst_changed = $false
    if(Test-Path $dst -PathType Container) {
      $dst_changed = $true
      $dst = Join-Path $dst $_.Value.src_basename
    }
    New-Object psobject -Property @{
      chk_exists = ($exists = Test-Path $dst -PathType Leaf)
      src_md5 = ($sMd5 = $_.Key)
      dst_md5 = ($dMd5 = if ($exists) { Get-MD5Sum $dst } else { $null })
      chk_dirty = ($dirty = if ($sMd5 -ne $dMd5) { $true } else { $false })
      verifies = if ($dirty -eq $false) { $true } else { $false }
      target_is_folder = $dst_changed
    }
  } | Select-Object -Property chk_exists,src_md5,dst_md5,chk_dirty,verifies,target_is_folder
}

Function Get-MD5Sum($src) {
  Try {
    $c = [System.Security.Cryptography.MD5]::Create()
    $bytes = $c.ComputeHash(($in = (Get-Item $src).OpenRead()))
    return ([System.BitConverter]::ToString($bytes)).Replace("-", "").ToLower()
  } 
  Finally {
    Cleanup $c
    Cleanup $in
  }
}

Function Unresolve-Path($path) {
  if ($path -eq $null) {
    return $null
  }
  else {
    return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($path)
  }
}

Check-Files $hash_file | ConvertTo-Csv -NoTypeInformation

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.0.1/lib/winrm-fs/scripts/check_files.ps1.erb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.0.1/lib/winrm-fs/scripts/check_files.ps1.erb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.0.1/lib/winrm-fs/scripts/check_files.ps1.erb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.0.1/lib/winrm-fs/scripts/check_files.ps1.erb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.0.1/lib/winrm-fs/scripts/check_files.ps1.erb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.0.1/lib/winrm-fs/scripts/check_files.ps1.erb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/winrm-fs-1.0.1/lib/winrm-fs/scripts/check_files.ps1.erb
winrm-fs-1.0.1 lib/winrm-fs/scripts/check_files.ps1.erb
winrm-fs-1.0.0 lib/winrm-fs/scripts/check_files.ps1.erb