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

Fixed exception in archive consumer. #610

Merged
merged 2 commits into from
Jun 6, 2017
Merged

Fixed exception in archive consumer. #610

merged 2 commits into from
Jun 6, 2017

Conversation

konstantin-popov
Copy link
Contributor

The package throws exception on Windows when archive-view uses it in archive with nested files/directories.

Not sure if importing path is ok here or it should go somewhere in Atom-FS package for abstraction.

@Alhadis
Copy link
Member

Alhadis commented Jun 6, 2017

Hey there,

I'm afraid this isn't really fixing the underlying issue. You see, the way the filesystem API works is that it normalises path separators the first time a resource is referenced, freeing all other functions to assume forward slashes in paths are being used.

So the real problem is somewhere along the lines, separators aren't being normalised like they should be. Could I trouble you to email me the ZIP file (or something with an analogous structure)?

@konstantin-popov
Copy link
Contributor Author

I found the problem and tested the fix using one of the test files in archive-viewer package, this tar file.

Is this what you need?

@konstantin-popov
Copy link
Contributor Author

So the real problem is somewhere along the lines, separators aren't being normalised like they should be.

The source of backslashes is here (package node-ls-archive used by archive-viewer to list archives' contents). Surprisingly for me, it seems to replace all forward slashes with backslashes not only on Windows. Any idea why is it so?

@Alhadis
Copy link
Member

Alhadis commented Jun 6, 2017

Nope, no idea. But I'm looking into this to see what the real issue is.

I doubt the solution is as simple as using path.sep, however.

@Alhadis
Copy link
Member

Alhadis commented Jun 6, 2017

@konstantin-popov Never mind. I forgot what I wrote stitchPath for: and it's not even related to the filesystem API whatsoever.

@@ -1,5 +1,6 @@
"use strict";

const pathModule = require("path");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use this instead?

const {sep} = require("path");

@Alhadis Alhadis merged commit b3c2537 into file-icons:master Jun 6, 2017
@Alhadis
Copy link
Member

Alhadis commented Jun 6, 2017

Thanks!

Alhadis added a commit that referenced this pull request Jun 6, 2017
@konstantin-popov konstantin-popov deleted the fix-archive-consumer branch June 6, 2017 10:25
@konstantin-popov
Copy link
Contributor Author

@Alhadis, after what I have seen in node-ls-archive I thought that this patch should be tested on Mac/Linux (system with a different path separator). Do you happen to use any of these?

@Alhadis
Copy link
Member

Alhadis commented Jun 6, 2017

Yes, don't worry. My normal system is running macOS; I tested your earlier fix with a VirtualBox install of Windows 7. Both platforms are functioning fine, it would seem. =)

Note that the stitchPaths method was added to smooth over an inconsistency from atom/archive-view#45. Basically, their DirectoryView objects lack the same path-properties which FileView instances are given. We needed both DirectoryView and FileView classes to both have an archive-relative path... :\

@Alhadis
Copy link
Member

Alhadis commented Jun 6, 2017

BTW, all of this ugly code will be washed away once/if the Atom team merges atom/archive-view#47. Because what we're currently doing now, in order to get icons attached to DOM elements, is apply one sneaky monkey-patch after another... :( You can read more on that topic in the PR.

@konstantin-popov
Copy link
Contributor Author

Thanks for your explanation! I thought something like this when looking at punchClass method. 😃

@Alhadis
Copy link
Member

Alhadis commented Jun 6, 2017

Yeah, haha. =) In fact, the entire lib/consumers folder is full of such hacky, vile code: hopefully we're able to purge it all sooner rather than later. Everything's all up to the Atom team, though, and whether they want to accept my PRs (if they don't, uh, I'm not sure how much longer the consumers hacks will be hanging around for... 😢 )

@Alhadis Alhadis added bug Confirmed defect in package logic, deprecation notices, and PRs which fix them. consumers Issues related to monkey-patching of core packages prior to Atom consuming the new icon-service. labels Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed defect in package logic, deprecation notices, and PRs which fix them. consumers Issues related to monkey-patching of core packages prior to Atom consuming the new icon-service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants