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

Case sensitivity issue #96

Open
stevenb256 opened this issue Mar 14, 2016 · 14 comments
Open

Case sensitivity issue #96

stevenb256 opened this issue Mar 14, 2016 · 14 comments
Labels

Comments

@stevenb256
Copy link

If I start a watch with a path that doesn't match the case sensitivity of whats in the file system, events get filtered out and not sent. I had an email exchange with you about this.

doesn't work
err := notify.Watch("/users/sbailey/...", c, notify.All)

works

err := notify.Watch("/Users/sbailey/...", c, notify.All)
@rjeczalik rjeczalik added the bug label Mar 14, 2016
@nathany
Copy link
Collaborator

nathany commented Mar 15, 2016

which operating system and file system is this issue for?

@rjeczalik
Copy link
Owner

@nathany Oh sorry, we were discussing it over e-mail - it's for fsevents.

@stevenb256
Copy link
Author

Yes was in macos. I'll see if it repro on Windows.

Sent from Outlook Mobilehttps://aka.ms/qtex0l

On Tue, Mar 15, 2016 at 9:33 AM -0700, "Rafal Jeczalik" <[email protected]mailto:[email protected]> wrote:

@nathanyhttps://github.com/nathany Oh sorry, we were discussing it over e-mail - it's for fsevents.

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#96 (comment)

@nathany
Copy link
Collaborator

nathany commented Mar 15, 2016

Using Case Sensitive HFS+?

@stevenb256
Copy link
Author

No.

Sent from Outlook Mobilehttps://aka.ms/qtex0l


From: Nathan Youngman <[email protected]mailto:[email protected]>
Sent: Tuesday, March 15, 2016 12:18 PM
Subject: Re: [notify] Case sensitivity issue (#96)
To: rjeczalik/notify <[email protected]mailto:[email protected]>
Cc: Steven Bailey <[email protected]mailto:[email protected]>

Using Case Sensitive HFS+?

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHubhttps://github.com//issues/96#issuecomment-196981643

@nathany
Copy link
Collaborator

nathany commented Mar 15, 2016

Oh. That is odd. Here is a similar issue in nodejs: paulmillr/chokidar#418 It sounds like it's something FSEvents itself does.

@rjeczalik
Copy link
Owner

@nathany The problem is if you set a watch on /users/rjeczalik/test then any incoming event will have a path with a proper case, /Users/rjeczalik/test/test in this case.

Example:

package main

import (
        "log"

        "github.com/rjeczalik/notify"
)

func main() {
        c := make(chan notify.EventInfo, 1)

        if err := notify.Watch("/users/rjeczalik/test/", c, notify.All); err != nil {
                log.Fatal(err)
        }
        defer notify.Stop(c)

        ei := <-c
        log.Println("event", ei)
}
$ go run -tags debug notify.go # run it with debug on
$ touch ~/test/test # create a file

The program will output:

[D] notify.FSEventsInodeMetaMod|notify.FSEventsIsFile (0x10400) (/Users/rjeczalik/test/test, i=0, ID=182167788, len=1)

The solution would be to call or replace canonicalPath with realpath from tools/x/sys repository.

@stevenb256
Copy link
Author

I'm not seeing the issue on Windows.

@nathany
Copy link
Collaborator

nathany commented Mar 15, 2016

Would it be possible to just fix /users/rjeczalik/test to the actual path at the beginning of Watch? I'm curious if filepath.Abs or similar would fix it up?

@rjeczalik
Copy link
Owner

Would it be possible to just fix /users/rjeczalik/test to the actual path at the beginning of Watch?

Yup, that's the plan, we'll need realpath syscall for that.

@stevenb256
Copy link
Author

Glad you guys know the issue. I tried to find a workaround where I read DIR names from the file system to see if I get back the correct case and then reconstruct the path that i passed to Watch but the Stat API still returns the Users directory with a lower case u (users). So no way for me to get correct case or real path from Go.

On Mar 15, 2016, at 3:08 PM, Rafal Jeczalik <[email protected]mailto:[email protected]> wrote:

Would it be possible to just fix /users/rjeczalik/test to the actual path at the beginning of Watch?

Yup, that's the plan, we'll need realpath syscall for that.

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHubhttps://github.com//issues/96#issuecomment-197047075

@stevenb256
Copy link
Author

I figured out a work around where I can use ReadDirNames and get the case corrected path to pass into Watch. but, a fix would still be appreciated.

/* ---------------------------------------------------------------------------------------*/
func GetCaseCorrectBase(path string) string {
base := filepath.Base(path)
file, err := os.Open(filepath.Dir(path))
if checkerror(err) {
return base
}
defer file.Close()
correctBases, err := file.Readdirnames(-1)
if checkerror(err) {
return base
}
for _, correctBase := range correctBases {
if strings.ToLower(correctBase) == strings.ToLower(base) {
return correctBase
}
}
return base
}

/* ---------------------------------------------------------------------------------------*/
func GetCaseCorrectPath(path_a string) string {
var reversed []string
var path = path_a
for "" != path && string(filepath.Separator) != path {
reversed = append(reversed, GetCaseCorrectBase(path))
path = filepath.Dir(path)
}
var new_path_a string
for i:= len(reversed) - 1; i >= 0; i-- {
new_path_a += string(filepath.Separator) + reversed[i]
}
return Clean(new_path_a)
}

@dahovey
Copy link

dahovey commented Nov 13, 2019

I ran into this issue using skaffold on macOS as well. Issue here

A fix would be appreciated. I was able to rename directory but lost a lot of time.

@cameronelliott
Copy link

Like @dahovey I sure spent a lot of time trying to understand why a project dependent upon this package did not work at all. #96 (comment)
It was because, using shell, I was in folder ~/documents/x, and not in ~/Documents/x for the cwd.

I filed an issue to help users there if they have the same issue: cortesi/modd#102

That said, I really appreciate this exists, and thank you for the fantastic contribution to the eco-system! ❤️

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

No branches or pull requests

5 participants