Code Monkey home page Code Monkey logo

Comments (22)

activescott avatar activescott commented on September 20, 2024

This error is coming directly from the low-level CAB APIs which is a native C lib calling Win32 and not .NET - so it isn't .NET causing these errors. That code is all checked in at https://github.com/activescott/libmspack4n if you want to investigate and provide a fix that works with the longer file names using whatever Win32 APIs work (while still validating file paths). As long as the code is clean and tests pass I'll be more than happy to accept PRs there.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

Thank you. I did some experiments with libmspack4n in order to move the handling of long paths there, as you suggested, and it almost works: while the call to mspack_invoke_mscab_decompressor_extract handles long paths correctly, the same method (ExtractTo) then proceeds with some time-stamp and attribute modification in .NET code which I had to comment out. Converting those (File.SetCreationTime, File.SetLastWriteTime and File.SetAttributes) to win32 calls as well should do the trick, I suppose.

Half-finished patch attached to show what I mean; it's the first time I use either C# or Visual Studio, so please show some mercy. I could try finishing the patch with win32 calls for setting the file attributes and time-stamps if you agree that it is the correct solution.
libmspack4n-longfilename-unfinished.patch.txt

from lessmsi.

activescott avatar activescott commented on September 20, 2024

@mattiase Thanks! I have no concerns on the approach. As long as tests pass, I'll pull it.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

Good, I shall have a patch finished by tomorrow. Right now the tests don't work outside your timezone; something needs to be done about that. The timestamps in .CAB files lack any timezone information and are treated as local times when files are extracted. However, the metadata reference files for the tests contain dates with specified timezones, making them absolute points in time. As a result, these tests always fail when I run them here.

The simplest fix is to remove the timezone information from all .csv files under TestFiles/ExpectedOutput: just delete the "-08:00" or "-07:00" suffix of each time stamp (usually two per line). The test will then treat these timestamps as local times, and the test succeeds no matter where on Earth they are run.

I could send you a patch for this if you like, but it's just a simple mechanical change, and the generation code should be updated accordingly as well so that they will be generated without the timezone part next time.

from lessmsi.

activescott avatar activescott commented on September 20, 2024

thanks. love the idea of removing timezone suffix from generation code and test files!
Looking forward to the PRs!.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

The pull requests are there, one for libmspack4n and one for lessmsi.

from lessmsi.

activescott avatar activescott commented on September 20, 2024

Thanks for the PRs! I'll get to these as soon as I can. Probably this weekend. Thanks again!

On Apr 19, 2016, at 01:17, mattiase [email protected] wrote:

The pull requests are there, one for libmspack4n and one for lessmsi.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

from lessmsi.

activescott avatar activescott commented on September 20, 2024

@mattiase thanks again for the PRs. Can you point me to a msi that actually exhibits this problem so that I can double-check it before creating a release?

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

You can use any MSI that you have, as long as you unpack it into a directory long enough so that the combined length of the base directory and at least one of the files in the MSI exceeds 260 characters.

For instance, the longest file name inside python-2.7.3.msi file in your tree is SourceDir/Windows/winsxs/x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91/x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375.manifest at 173 characters. If you try unpacking that MSI into a directory that is at least 260-173 = 87 characters long, then it will fail without the fix, but succeed with the fix.

Try, for instance, the directory c:\my\own\very\very\very\unusually\long\directory\name\with\cream\sugar\and\chocolate\topping (I just did!) and you will see.

from lessmsi.

activescott avatar activescott commented on September 20, 2024

Doh, guess I should have thought that through, but thanks for the specific example. I gave this a shot and even with the libmspack4n updates, still encounter a problem. Seems that GetTargetDirectory in Wixtracts (LessMsi.Core) is trying to use System.IO to identify the target directory and it ran into problems. I'm working on fixes for that, but before I continue, I want to make sure that I'm not missing anything. Don't you encounter the same thing? I'm using what is currently in master.

P.S. I found it kind of funny that almost nothing works with those paths. Even cmd.exe, total commander, and more all had weird failures. Good thing I have cygwin and bash installed which work fine with the long windows paths 😜

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

It does work for me in the extract-all-to-directory form, lessmsi x package.msi destdir\, and that's what we primarily use lessmsi for. Are you selecting a specific directory to extract?

Yes, those "extended" paths aren't recognised much even by Microsoft's own tools, but often they are the only way out. I mostly use cygwin too.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

It is true that if the combined length of the destination root directory and the longest directory of any file being extracted exceeds 260 characters, then extraction still fails (in GetTargetDirectory, as you observe). That was not a problem I had, but someone else might; in that case, a few more operations need to be replaced with win32 calls: Directory.CreateDirectory in GetTargetDirectory, and a few calls to File.Exists and Directory.Exists. In addition, some Path.Combine operations need to be replaced with plain string concatenations.

I have no immediate plan to do this right now. Is it holding up a release for you?

from lessmsi.

activescott avatar activescott commented on September 20, 2024

@mattiase sorry for my delay on this. Thanks for confirming that I'm not missing anything. I have a local branch here where I'm working on this. I'm swamped right now with a combination of work and personal activities, but I hope to get back to this and wrap it up over the next week or two.

from lessmsi.

activescott avatar activescott commented on September 20, 2024

@mattiase could you please try the branch at https://github.com/activescott/lessmsi/tree/tested_support_for_long_paths and see if it works for you and your needs. I tried to add support throughout. If you run into something not working I'd love to have a test added.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

That branch (tested_support_for_long_paths) works for my purposes (absolute path of longest destination file exceeds 260 characters but not its parent directory), but it already worked after my submitted fix that you commited.

However, even in this branch, I wasn't able to extract python-2.7.3.msi to a directory 166 characters long; the call to Directory.CreateDirectory in LessMsi.Msi.Wixtracts.GetTargetDirectory fails.

from lessmsi.

activescott avatar activescott commented on September 20, 2024

Okay the branch at https://github.com/activescott/lessmsi/tree/tested_support_for_long_paths contains a longer output path which revealed more issues throughout the code and this latest commit now has a fix for them.

@mattiase I will be grateful if you can give that code a quick build and test to make sure it's all working for you now.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

Thank you! It seems to work as far as I have tested it, but I haven't tried it on UNC paths, and I wonder if the conversion to extended path form is done correctly. Unless I'm mistaken, the long form of \\server\thing\stuff is not anything like \\?\\\server\thing\stuff but literally \\?\UNC\server\thing\stuff, as implemented in MSCompressedFile.LongFilename.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

I tried extracting to an UNC path, and it does not work at all (even for short paths) because of the reason described in my previous comment.

from lessmsi.

activescott avatar activescott commented on September 20, 2024

Thanks for the feedback. Its on my list

from lessmsi.

activescott avatar activescott commented on September 20, 2024

Only thing left is:

from lessmsi.

activescott avatar activescott commented on September 20, 2024

I believe this has been resolved back with recent versions of LessIO. I'm not sure if any window application -including windows explorer- supports long paths as well as LessMSI now :)

Let me know if I'm missing something and I'll fix it.

from lessmsi.

mattiase avatar mattiase commented on September 20, 2024

Thank you – unfortunately I'm no longer in a position to verify its functioning in this respect, but I'll take your word for it.

from lessmsi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.