Skip to content

Commit

Permalink
Fixes #4: If a symlink points to a dir, skip it instead of listing it…
Browse files Browse the repository at this point in the history
… as a sequence result

Signed-off-by: Justin Israel <[email protected]>
  • Loading branch information
justinfx committed Jan 25, 2016
1 parent f17e816 commit 606066c
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fileseq.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"strings"
)

const Version = "2.0.0"
const Version = "2.0.1"

var (
padding map[string]int
Expand Down
18 changes: 18 additions & 0 deletions fileseq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,21 @@ func TestFindSequenceOnDisk(t *testing.T) {
}
}
}

func TestHandleSymlinksOnDisk(t *testing.T) {
seqs, err := FindSequencesOnDisk("testdata/versions")
if err != nil {
t.Fatal(err.Error())
}

if len(seqs) != 1 {
t.Fatalf("Expected 1 result ; got %d : %v", len(seqs), seqs)
}

actual := seqs[0].String()
expected := "testdata/versions/seq.1-10#.ext"

if actual != expected {
t.Fatalf("Expected to find seq %q ; got %q", expected, actual)
}
}
15 changes: 15 additions & 0 deletions sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,21 @@ func findSequencesOnDisk(path string, opts ...FileOption) (FileSequences, error)
continue
}

// Also skip symlinks that point to directories
if (info.Mode() & os.ModeSymlink) != 0 {
buf.WriteString(info.Name())
syminfo, err := os.Stat(buf.String())
if err != nil {
return nil, fmt.Errorf("Error reading symlink %q: %s", buf.Bytes(), err)
}

buf.Truncate(size)

if syminfo.IsDir() {
continue
}
}

name := info.Name()

if !hiddenFiles && strings.HasPrefix(name, ".") {
Expand Down
Empty file.
Empty file.
Empty file.
Empty file added testdata/versions/seq.0001.ext
Empty file.
Empty file added testdata/versions/seq.0002.ext
Empty file.
Empty file added testdata/versions/seq.0003.ext
Empty file.
Empty file added testdata/versions/seq.0004.ext
Empty file.
Empty file added testdata/versions/seq.0005.ext
Empty file.
Empty file added testdata/versions/seq.0006.ext
Empty file.
Empty file added testdata/versions/seq.0007.ext
Empty file.
Empty file added testdata/versions/seq.0008.ext
Empty file.
Empty file added testdata/versions/seq.0009.ext
Empty file.
Empty file added testdata/versions/seq.0010.ext
Empty file.
1 change: 1 addition & 0 deletions testdata/versions/v3
1 change: 1 addition & 0 deletions testdata/versions/v4
1 change: 1 addition & 0 deletions testdata/versions/v5

0 comments on commit 606066c

Please sign in to comment.