fix order of throw and cleanup

master
lub 1 year ago
parent e293626dcb
commit ecb00a2aba

@ -55,7 +55,6 @@ $nextcloudPath = $config.Path + '/' + $webpName
$uploadSplat = @{
Authentication = 'Basic'
#Credential = New-Object System.Management.Automation.PSCredential (($config.Password | ConvertFrom-SecureString -AsPlainText), (New-Object System.Security.SecureString))
Credential = $config.Credential
Method = 'Put'
Uri = '{0}/remote.php/dav/files/{1}/{2}' -f $config.BaseUrl,$config.Credential.UserName,$nextcloudPath
@ -64,8 +63,8 @@ $uploadSplat = @{
try {
Invoke-RestMethod @uploadSplat
} catch {
throw $_
Remove-Item $webpPath
throw $_
}
$shareSplat = @{
@ -85,11 +84,10 @@ $shareSplat = @{
try {
$share = Invoke-RestMethod @shareSplat
} catch {
throw $_
Remove-Item $webpPath
throw $_
}
$share.ocs.data.url + '/preview' | wl-copy --trim-newline
notify-send 'Screenshot URL in clipboard' --expire-time=1000
Remove-Item $webpPath

Loading…
Cancel
Save