Skip to content

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

Open
kou1okada wants to merge 2 commits into
ttilley:masterfrom
kou1okada:master
Open

Bugfix for FSSM::Tree::Cache on UNC.#46
kou1okada wants to merge 2 commits into
ttilley:masterfrom
kou1okada:master

Conversation

@kou1okada
Copy link
Copy Markdown

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.

1 participant