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

Add an overwrite option #167

Open
Maxim-Mazurok opened this issue Jun 8, 2021 · 12 comments
Open

Add an overwrite option #167

Maxim-Mazurok opened this issue Jun 8, 2021 · 12 comments

Comments

@Maxim-Mazurok
Copy link

Maxim-Mazurok commented Jun 8, 2021

Describe the bug
Please, add "overwrite" files in the destination option. Instead of adding *.duplicate1 files, I'd like lessmsi to overwrite files in the destination.

To Reproduce
Steps to reproduce the behavior:

  1. Use lessmsi to extract some msi
  2. Use lessmsi to extract the same msi
  3. Observe *.duplicate1 files, and no option to overwrite instead

Expected behavior
I'd like to have an option to overwrite dest files

Desktop (please complete the following information):

  • OS: Windown 11
  • lessmsi: v2.1.0
@activescott
Copy link
Owner

Thanks @Maxim-Mazurok. CLI or GUI?

If you or or anyone else is interested in contributing let me know. Happy to discuss or help guide in any way at all.

@Maxim-Mazurok
Copy link
Author

I'm using CLI, thanks in advance :)

@mega5800
Copy link
Contributor

Hello @Maxim-Mazurok.

Recently, new extraction commands “xfo” and “xfr” were added to the LessMSI CLI.
These commands extract all the MSI files into one folder location without the original folder structure and either overwrites files with identical names (xfo) or renames them with a count suffix (xfr).

Perhaps, these commands will help you achieve your goal.
If not, I’d love to take care of this ticket.

Thank you.

@Maxim-Mazurok
Copy link
Author

I probably need to preserve folder structure, I'm unpacking nodejs.msi to use as a local install, and I would imagine that structure matters since some files might reference other files from installation by relative path. Thanks @mega5800 :)

@mega5800
Copy link
Contributor

@Maxim-Mazurok Thank you for your response, I understand your use case much better now.

I'd like to take care of this ticket, and will be grateful if you could update your ticket description using the latest version of LessMSI.

There years have passed since this ticket was opened, and the latest state of this feature would be beneficial for my dev work.

@activescott Can you please assign this ticket to me?

Thank you.

@Maxim-Mazurok
Copy link
Author

No worries!
I've updated description and tried with the latest release, the behaviour is the same.

Here's an extract from our cmd script that uses lessmsi:

:: manually make sure you have the latest release of lessmsi in %CI_FOLDER%

:: remove old lessmsi
if exist %CI_FOLDER%\lessmsi rmdir /s /q %CI_FOLDER%\lessmsi

:: extract lessmsi.zip
powershell -NoExit -Command "Get-ChildItem (Join-Path %CI_FOLDER% lessmsi-*.zip) | foreach {Expand-Archive $_.FullName -DestinationPath (Join-Path %CI_FOLDER% lessmsi)}; exit;"

:: remove old NodeJS local install
if exist %CI_FOLDER%\nodejs rmdir /s /q %CI_FOLDER%\nodejs

:: extract NodeJS msi ot create a portable/local installation of node
%CI_FOLDER%\lessmsi\lessmsi x %_node_msi_path% %CI_FOLDER%\nodejs\ >NUL

:: remove new lessmsi
rmdir /s /q %CI_FOLDER%\lessmsi

:: set PATH to use new node
set "PATH=%CI_FOLDER%\nodejs\SourceDir\nodejs;%PATH%"

Hope this helps, cheers!

@activescott
Copy link
Owner

@mega5800 Can you please look at #187 and see if it is related. I suspect that it is. I left a comment explaining what I think is a good solution there after investigating. Essentially in some cases 64bit and 32bit dlls have the same name and in the current logic resolve to the same root path and end up appearing to be duplicates, but they're not actually duplicates. They just have a duplicate name. So if we were to overwrite those, you might get 32bit or 64bit version (whichever happened to be extracted last).
The fix is outlined in my comment and is just a way to make that root directory unique.

I bet if we fix that one, there wouldn't be duplicate files anymore for this one, and I remember seeing some other issues that I thought were related to that one.

@Maxim-Mazurok
Copy link
Author

Maxim-Mazurok commented Jul 17, 2024

Well, in my case I'm just extracting msi multiple times into the same folder, when we're running our CI scripts on local. In CI it wouldn't be an issues because it creates new temp folder for each build. But on local we use the same folder on each run.

But yeah, I see where you're coming from, you probably don't really know if that's a file that was left by a previous extraction, or is it a different bittness DLL.

TBH it's not a big deal for me to clear the folder manually, it's just that I was surprised that lessmsi has this extra logic to preserve old files and add duplicate files, now I see there's sorta reason behind it.

@activescott
Copy link
Owner

Thanks for the feedback @Maxim-Mazurok Sounds like you would still like the overwrite option (in an ideal world). I guess I'd like to see #187 resolved first as overwrite + that bug might leave some unexpected results.

@mega5800
Copy link
Contributor

mega5800 commented Oct 5, 2024

Hello @Maxim-Mazurok.

I have been thinking about your ticket and would like to suggest the next solution.
In my first message in this thread, I suggested using the flat extraction options ('xfo' and 'xfr').
However, these options didn't quite fit your needs as you'd like to preserve the folder structure.

So I thought about introducing a similar extraction option named 'xo' ('o' stands for overwrite).
This option will produce the same output as a regular extraction done by the 'x', but without any files with the suffix .duplicate1.
I believe this option fits your needs much batter, please let me know what do you think about that?

@activescott, I'd like to hear your opinion as well regarding this proposal.

@Maxim-Mazurok
Copy link
Author

Thanks @mega5800, this should solve my use-case :)

@activescott
Copy link
Owner

I'm okay with it @mega5800 . You know the drill with tests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants