sync-to-remote.ps1 750 B

12345678910111213141516
  1. param(
  2. [Parameter(Mandatory=$true)][string]$Source,
  3. [Parameter(Mandatory=$true)][string]$RemotePartial,
  4. [Parameter(Mandatory=$true)][string]$RemoteWorker,
  5. [ValidateRange(65536,268435456)][int]$ChunkBytes = 1048576,
  6. [ValidateRange(0,5)][int]$Retries = 5,
  7. [switch]$Replace
  8. )
  9. $ErrorActionPreference='Stop'
  10. if(-not $RemotePartial.EndsWith('.partial')){throw 'REMOTE_PARTIAL_SUFFIX_REQUIRED'}
  11. $destination=$RemotePartial.Substring(0,$RemotePartial.Length-8)
  12. $arguments=@('--remote-worker',$RemoteWorker,'--chunk-bytes',$ChunkBytes,'--retries',$Retries)
  13. if($Replace){$arguments+='--replace'}
  14. $arguments+=@('upload',$Source,$destination)
  15. & python (Join-Path (Split-Path -Parent $PSScriptRoot) 'remote_transfer.py') @arguments
  16. exit $LASTEXITCODE