From ecb00a2aba46b0fa98f7f473a4d6cd0c375ef25a Mon Sep 17 00:00:00 2001 From: lub Date: Wed, 2 Aug 2023 19:10:40 +0200 Subject: [PATCH] fix order of throw and cleanup --- dotfiles/bin/.bin/nextcloud-screenshot.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dotfiles/bin/.bin/nextcloud-screenshot.ps1 b/dotfiles/bin/.bin/nextcloud-screenshot.ps1 index 9f99e86..4440834 100755 --- a/dotfiles/bin/.bin/nextcloud-screenshot.ps1 +++ b/dotfiles/bin/.bin/nextcloud-screenshot.ps1 @@ -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 -