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

Bugfix for FSSM::Tree::Cache on UNC. #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kou1okada
Copy link

Maybe, this problem occurs only under the cygwin environment.

Cause of a problem:

Pathname("//host/share").join("hoge.txt")
# => #<Pathname://host/sharehoge.txt>
Pathname("//host/share/").join("hoge.txt")
# => #<Pathname://host/share/hoge.txt>

This makes corruption at FSSM::Pathname.for().join() in FSSM::Tree::NodeEnumerable.each().
Therefore FSSM::Tree::Cache.files is not work correctly on UNC.
This patch modifies the behavior as below.

before:

FSSM::Pathname.for("//host/share/hoge.txt").segments
# => ["//host/share", "hoge.txt"]
cache = FSSM::Tree::Cache.new
# => #<FSSM::Tree::Cache:0x00000600440b28 @children={}>
cache.set "//host/share/hoge.txt"
# => 2014-02-25 11:38:19 +0900
cache.files
# => {"//host/sharehoge.txt"=>2014-02-25 11:38:19 +0900}

after:

FSSM::Pathname.for("//host/share/hoge.txt").segments
# => ["//host/share/", "hoge.txt"]
cache = FSSM::Tree::Cache.new
# => #<FSSM::Tree::Cache:0x0000060003e660 @children={}>
cache.set "//host/share/hoge.txt"
# => 2014-02-25 11:38:19 +0900
cache.files
# => {"//host/share/hoge.txt"=>2014-02-25 11:38:19 +0900}

Maybe, this problem occurs only under the cygwin environment.
The FSSM::Pathname.segments method did not work correctly. Therefore reconnection with join method failed to insert File::SEPARA

This problem makes failure for watch sub-command of compass (http://compass-style.org/).

before:

    FSSM::Pathname.for("/tmp/foo").segments
    # => ["//", "tmp", "foo"]
    FSSM::Pathname.for("/tmp/foo").join("bar")
    # => #<Pathname:/tmp/foo/bar>
    # OK, no problem. But a result of segments is a little bit strange.

    FSSM::Pathname.for("//host/share/foo").segments
    # => ["//", "host", "share", "foo"]
    FSSM::Pathname.for("//host/share/foo").join("bar")
    # => #<Pathname://host/share/foo/bar>
    # OK, no problem. But a result of segments is a little bit strange.

    cache = FSSM::Tree::Cache.new
    # => #<FSSM::Tree::Cache:0x00000600730888 @children={}>
    cache.set "/tmp/foo"
    # => 2014-02-13 23:20:19 +0900
    cache.files
    # => {"//tmpfoo"=>2014-02-13 23:20:19 +0900}
    # Oops!!! The path is corrupted. It's a problem!!!

after:

    FSSM::Pathname.for("/tmp/foo").segments
    # => ["/", "tmp", "foo"]
    FSSM::Pathname.for("/tmp/foo").join("bar")
    # => #<Pathname:/tmp/foo/bar>
    # OK, no problem. A result of segments is also reasonable.

    FSSM::Pathname.for("//host/share/foo").segments
    # => ["//host/share", "foo"]
    FSSM::Pathname.for("//host/share/foo").join("bar")
    # => #<Pathname://host/share/foo/bar>
    # OK, no problem. A result of segments is also reasonable.

    cache = FSSM::Tree::Cache.new
    # => #<FSSM::Tree::Cache:0x00000600272878 @children={}>
    cache.set "/tmp/foo"
    # => 2014-02-13 23:20:19 +0900
    cache.files
    # => {"/tmp/foo"=>2014-02-13 23:20:19 +0900}
    # OK, fixed a problem.
Maybe, this problem occurs only under the cygwin environment.

Cause of a problem:

    Pathname("//host/share").join("hoge.txt")
    # => #<Pathname://host/sharehoge.txt>
    Pathname("//host/share/").join("hoge.txt")
    # => #<Pathname://host/share/hoge.txt>

This makes corruption at FSSM::Pathname.for().join() in FSSM::Tree::NodeEnumerable.each().
Therefore FSSM::Tree::Cache.files is not work correctly on UNC.
This patch modifies the behavior as below.

before:

    FSSM::Pathname.for("//host/share/hoge.txt").segments
    # => ["//host/share", "hoge.txt"]
    cache = FSSM::Tree::Cache.new
    # => #<FSSM::Tree::Cache:0x00000600440b28 @children={}>
    cache.set "//host/share/hoge.txt"
    # => 2014-02-25 11:38:19 +0900
    cache.files
    # => {"//host/sharehoge.txt"=>2014-02-25 11:38:19 +0900}

after:

    FSSM::Pathname.for("//host/share/hoge.txt").segments
    # => ["//host/share/", "hoge.txt"]
    cache = FSSM::Tree::Cache.new
    # => #<FSSM::Tree::Cache:0x0000060003e660 @children={}>
    cache.set "//host/share/hoge.txt"
    # => 2014-02-25 11:38:19 +0900
    cache.files
    # => {"//host/share/hoge.txt"=>2014-02-25 11:38:19 +0900}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant