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

move: support changing case in case-insensitive systems #801

Closed
wants to merge 13 commits into from

Conversation

manidlou
Copy link
Collaborator

Resolves #759.

@manidlou manidlou self-assigned this May 16, 2020
@manidlou manidlou added this to the 10.0.0 milestone May 16, 2020
@manidlou manidlou linked an issue May 16, 2020 that may be closed by this pull request
@RyanZim
Copy link
Collaborator

RyanZim commented May 16, 2020

@manidlou Did you verify this actually changes the case displayed in the file manager or on the command line, for Mac or Windows?

@manidlou
Copy link
Collaborator Author

@RyanZim that's definitely required and I wanted to do that but I don't have neither of those systems. I appreciate if anyone could verify that on Mac and Windows! Feel free to let me know if the changes don't work and I will work on it then! I also might be able to have access to my friend's macbook tomorrow, so I'll let you know then.

@manidlou
Copy link
Collaborator Author

I verified that on Mac and it successfully changed the case.

Copy link
Collaborator

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

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

Works now perfectly on my Mac

manidlou and others added 2 commits June 21, 2020 13:31
No breaking changes for us, just performance improvements
lib/util/stat.js Outdated
@@ -11,6 +11,8 @@ const lstat = (file) => nodeSupportsBigInt ? fs.lstat(file, { bigint: true }) :
const statSync = (file) => nodeSupportsBigInt ? fs.statSync(file, { bigint: true }) : fs.statSync(file)
const lstatSync = (file) => nodeSupportsBigInt ? fs.lstatSync(file, { bigint: true }) : fs.lstatSync(file)

const isCaseInsensitiveSystem = process.platform === 'darwin' || process.platform === 'win32'

Choose a reason for hiding this comment

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

Linux also has case-insensitive filesystems, and it can network mount CIFS which is also case-insensitive. So the only way to test this is to see if you can access a file on the filesystem you want to work with via another casing that doesn't exist yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that it doesn't include all case-insensitive file systems. Basically a better approach would be to actually probe the file system to find out about its case-sensitivity. It might have some performance drawback but ultimately that would be a better approach.

Choose a reason for hiding this comment

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

But wouldn't you have to do that for every directory you access?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If directories are mounted on different file systems, yes! Basically, finding case-sensitivity of a file system is a complex thing! If we want to be 100% safe, we need to check where the directories are mounted, and also if there is any subsystem that has its own case comparison table.

Choose a reason for hiding this comment

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

So wouldn't it be easier to just rename the file and pass any errors to the user instead?

lib/util/stat.js Outdated
const srcBaseName = path.basename(src)
const destBaseName = path.basename(dest)
if (funcName === 'move' &&
isCaseInsensitiveSystem &&

Choose a reason for hiding this comment

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

perhaps better to simply not test for this. If the stat() result is the same, it's the same file.

Choose a reason for hiding this comment

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

... And in that case, just call rename(). I can't think of a case where it would fail

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense! I am ok with not checking for case sensitivity of the system as this is not comprehensive enough!

@RyanZim
Copy link
Collaborator

RyanZim commented Jan 18, 2021

@manidlou ping!

@manidlou
Copy link
Collaborator Author

Sorry for the long pause! Been extremely busy! I will have a look at this again.

Copy link
Collaborator

@RyanZim RyanZim left a comment

Choose a reason for hiding this comment

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

LGTM; except test descriptions need updated, since there's nothing OS-specific anymore (shouldn't say "based on the OS").

@manidlou
Copy link
Collaborator Author

Since this will merge into v10, and I am a bit worried if we wait for long time, we might end up having some merge conflicts! So I merged current master into v10 and rebased this one so that we will have a clean merge!

@RyanZim
Copy link
Collaborator

RyanZim commented Feb 17, 2021

@manidlou Honestly, I suspect I'll end up manually cherry-picking everything related to v10, since it's taken so long. Just leave this PR as-is for now.

RyanZim pushed a commit that referenced this pull request Apr 1, 2021
@RyanZim
Copy link
Collaborator

RyanZim commented Apr 1, 2021

Landed on master in c8bd383.

@RyanZim RyanZim closed this Apr 1, 2021
@RyanZim RyanZim deleted the mani/move-case-insensitive branch April 1, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot move file to change case on case insensitive fs
7 participants