8LWXpg / ptr

PowerToys Run plugin manager
MIT License
26 stars 1 forks source link

Support different zip structure #10

Closed EDM115 closed 2 weeks ago

EDM115 commented 2 weeks ago

Description

If an archive containing a PT plugin have a top level folder inside that contains the plugin, it'll work (ex : https://github.com/8LWXpg/PowerToysRun-SSH/releases/download/v1.2.1/SSH-v1.2.1-x64.zip)
However if all the content of the plugin is directly at the root of the archive (ex : https://github.com/GTGalaxi/quick-lookup-ptrun/releases/download/v1.3.3/QuickLookup-v1.3.3.zip), then ptr will not extract the files correctly (one folder too high in the arborescence)

Steps to reproduce

  1. Have ptr installed
  2. Run ptr add QuickLookup GTGalaxi/quick-lookup-ptrun
  3. Notice that instead of having this :
    ❯❯ C:\Users\EDM115\AppData\Local\Microsoft\PowerToys\PowerToys Run\Plugins
    ❯ tree /F
    Structure du dossier pour le volume Windows-SSD
    Le numéro de série du volume est 64BC-ABC7
    C:.
    │   version.toml
    │
    └───QuickLookup
    │   plugin.json
    │   PowerToys.Common.UI.dll
    │   PowerToys.ManagedCommon.dll
    │   QuickLookup.dll
    │   tools.json
    │   Wox.Infrastructure.dll
    │   Wox.Plugin.dll
    │
    └───img
            ql.dark.png
            ql.light.png

    we have this :

    ❯❯ C:\Users\EDM115\AppData\Local\Microsoft\PowerToys\PowerToys Run\Plugins
    ❯ tree /F
    Structure du dossier pour le volume Windows-SSD
    Le numéro de série du volume est 64BC-ABC7
    C:.
    │   plugin.json
    │   PowerToys.Common.UI.dll
    │   PowerToys.ManagedCommon.dll
    │   QuickLookup.dll
    │   tools.json
    │   version.toml
    │   Wox.Infrastructure.dll
    │   Wox.Plugin.dll
    │
    └───QuickLookup
        ql.dark.png
        ql.light.png
8LWXpg commented 2 weeks ago

As stated in README, we need a separate logic on different zip structure, which I don't have a clear idea now.

EDM115 commented 2 weeks ago

maybe a check like this :

flowchart LR
    A{Does the archive have only a single directory inside ?} -- Yes --> B[Do what you already do];
    A -- No --> C{Is there at least one .dll file inside ?};
    C -- Yes --> D[Extract all the content of the archive in a new directory with the name that the user has chosen];
    C -- No --> E[Probably invalid archive, dunno how to process];
8LWXpg commented 2 weeks ago

I ended up using a completely different approach due to how ZipArchive structured. You can check it if you're curios.

https://github.com/8LWXpg/ptr/blob/754896eb77628ff1ef82bc3641e1a8e1682385a4/src/util.rs#L122-L152