Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Pre-Uninstall function of MobaXterm fails if configuration backup is not enabled #13960

Open
3 tasks done
sburkard opened this issue Sep 5, 2024 · 0 comments
Open
3 tasks done
Labels

Comments

@sburkard
Copy link

sburkard commented Sep 5, 2024

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues/PRs to ensure it has not already been reported or fixed.
  • I have verified that I am using the latest version of Scoop and corresponding bucket.

Package Name

mobaxterm

Expected/Current Behaviour

When I uninstall the mobaxterm package the pre_uninstall function throws an error if the configuration backup of scoop is disabled in the settings.

Steps to Reproduce

PS> scoop install extras/mobaxterm
Open MobaXterm > Settings > General
Disable configuration backup
Close MobaXterm > Moba deletes 'MobaXterm backup.zip'

PS> scoop uninstall extras/mobaxterm
Running pre_uninstall script...Get-ChildItem : Cannot find path 'C:\Users\UID20852\scoop\apps\mobaxterm\24.2\MobaXterm backup.zip' because it does
not exist.
At line:2 char:10
+     if ((Get-ChildItem "$dir\$file").LastWriteTime -gt (Get-ChildItem ...
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\UID208...term backup.zip:String) [Get-ChildItem], ItemNotFound
   Exception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

done.

Possible Solution

Add check if files exist before trying to access them: (Test-Path \"$dir\\$file\")

    "pre_uninstall": [
        "function UpdatesFile([string] $file) {",
        "    if ((Test-Path \"$dir\\$file\") -and ((Get-ChildItem \"$dir\\$file\").LastWriteTime -gt (Get-ChildItem \"$persist_dir\\$file\").LastWriteTime)) {",
        "        [System.IO.File]::WriteAllBytes(\"$persist_dir\\$file\", [System.IO.File]::ReadAllBytes(\"$dir\\$file\"))",
        "    }",
        "}",
        "@('MobaXterm backup.zip', 'MobaXterm.ini') | ForEach-Object { UpdatesFile $_ }"

Scoop and Buckets Version

Current Scoop version:
859d1db5 (HEAD -> master, tag: v0.5.2, origin/master, origin/HEAD) chore(release): Bump to version 0.5.2 (#6080)

'main' bucket:
00828bfa7 (HEAD -> master, origin/master, origin/HEAD) pulumi: Update to version 3.131.0

'extras' bucket:
4846176a9 (HEAD -> master, origin/master, origin/HEAD) yuescript: Update to version 0.25.1

'java' bucket:
12fb891d (HEAD -> master, origin/master, origin/HEAD) temurin8-nightly-jre: Update to version 8.0.432-3.0.202409030846

Scoop Config

last_update                       scoop_repo                              scoop_branch
-----------                       ----------                              ------------
2024-09-05T07:19:10.9436876+02:00 https://github.com/ScoopInstaller/Scoop master

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.19041.4648
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.4648
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Additional Softwares

No response

@sburkard sburkard added the bug label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant