lf icon indicating copy to clipboard operation
lf copied to clipboard

Renaming file by just capitalizing a letter

Open noib3 opened this issue 6 years ago • 10 comments

Renaming a file by just capitalizing one or more of its letters causes an error. For ex if I try to rename test to Test, I get the following error

portion_2020:04:29@02:38:47

noib3 avatar Apr 29 '20 00:04 noib3

I cannot reproduce this. What is your set shell?

BachoSeven avatar Apr 29 '20 01:04 BachoSeven

I have not set it, so it's the default one.

noib3 avatar Apr 29 '20 08:04 noib3

I got same problem. What's worse, the renamed file will disappear. My lf --version is 14, the lfrc is from the official example

asciicast

eggeek avatar May 12 '20 07:05 eggeek

what shell and terminal are you using? I still cannot reproduce it

BachoSeven avatar May 12 '20 10:05 BachoSeven

I cannot reproduce it too. as I know Windows and Mac are case-insensitive so maybe that cause the problem.

shabahengam avatar May 12 '20 15:05 shabahengam

I cannot reproduce it too. as I know Windows and Mac are case-insensitive so maybe that cause the problem.

Yes, I'm using macOS. But I also tried to set the shell by set shell zsh. And the renaming is work in my command line and in LF command mode e.g. %mv A.txt a.txt.

The problem is that I cannot find any log (under /tmp), thus I don't know how the LF execute the "rename" command that causes the file to disappear.

eggeek avatar May 12 '20 23:05 eggeek

I had a similar situation but get fixed.check this issue #253 maybe that issue is not completely fixed for other OSes.(I'm using Linux)

shabahengam avatar May 13 '20 00:05 shabahengam

@eggeek I don't know anything about go, but I digged around this points in the code: eval.go and nav.go; you can see from nav.go that there's a function called os.Rename imported from the package os, which you can find at https://golang.org/pkg/os/#Rename. It turns out that this function calls another rename function from this file. There, I found the following comment which could be useful to you:

                // However, if the old name and new name are not the same, yet
		// they refer to the same file, it implies a case-only
		// rename on a case-insensitive filesystem, which is ok.

Anyways, the function then seems to call yet another Rename function, this time from syscall: on an AMD64 architecture, it should be the one in here at line 1297. So the library called for the rename operation is probably libc_rename_trampoline.

I still have no idea what causes the error nor the file disappearance, but hopefully this can point you in a Darwin-oriented debugging of the issue.

BachoSeven avatar May 13 '20 00:05 BachoSeven

We fixed the older issue by simply checking if the new name is the same as old in a case-sensitive way which apparently fails for case-insensitive file systems. I'm not sure what would be the easiest way to fix this without adding some platform dependent code.

@n0ibe This is an important issue we should fix as soon as possible. Thanks for reporting.

gokcehan avatar Jun 03 '20 20:06 gokcehan

I have pushed a fix for this and everything should be working fine now. Closing this issue now.

gokcehan avatar Jun 17 '20 02:06 gokcehan