Skip to content

🎧 Your Personal Streaming Service

Unexport private functions

Deluana4183aea8cc1
diff --git a/scanner/change_detector.go b/scanner/change_detector.go
index dc64d6eee..f8e9705fc 100644
--- a/scanner/change_detector.go
+++ b/scanner/change_detector.go
@@ -62,12 +62,12 @@ func (s *ChangeDetector) loadDir(dirPath string) (children []string, lastUpdated
return
}
for _, f := range files {
- isDir, err := IsDirOrSymlinkToDir(dirPath, f)
+ isDir, err := isDirOrSymlinkToDir(dirPath, f)
// Skip invalid symlinks
if err != nil {
continue
}
- if isDir && !IsDirIgnored(dirPath, f) {
+ if isDir && !isDirIgnored(dirPath, f) {
children = append(children, filepath.Join(dirPath, f.Name()))
} else {
if f.ModTime().After(lastUpdated) {
@@ -78,12 +78,12 @@ func (s *ChangeDetector) loadDir(dirPath string) (children []string, lastUpdated
return
}
-// IsDirOrSymlinkToDir returns true if and only if the dirent represents a file
+// isDirOrSymlinkToDir returns true if and only if the dirent represents a file
// system directory, or a symbolic link to a directory. Note that if the dirent
// is not a directory but is a symbolic link, this method will resolve by
// sending a request to the operating system to follow the symbolic link.
// Copied from github.com/karrick/godirwalk
-func IsDirOrSymlinkToDir(baseDir string, dirent os.FileInfo) (bool, error) {
+func isDirOrSymlinkToDir(baseDir string, dirent os.FileInfo) (bool, error) {
if dirent.IsDir() {
return true, nil
}
@@ -98,7 +98,7 @@ func IsDirOrSymlinkToDir(baseDir string, dirent os.FileInfo) (bool, error) {
return dirent.IsDir(), nil
}
-func IsDirIgnored(baseDir string, dirent os.FileInfo) bool {
+func isDirIgnored(baseDir string, dirent os.FileInfo) bool {
_, err := os.Stat(filepath.Join(baseDir, dirent.Name(), consts.SkipScanFile))
return err == nil
}
diff --git a/scanner/change_detector_test.go b/scanner/change_detector_test.go
index 556e5806d..f6aff65a8 100644
--- a/scanner/change_detector_test.go
+++ b/scanner/change_detector_test.go
@@ -111,34 +111,34 @@ var _ = Describe("ChangeDetector", func() {
Expect(changed).To(ConsistOf(P("a/b")))
})
- Describe("IsDirOrSymlinkToDir", func() {
+ Describe("isDirOrSymlinkToDir", func() {
It("returns true for normal dirs", func() {
dir, _ := os.Stat("tests/fixtures")
- Expect(IsDirOrSymlinkToDir("tests", dir)).To(BeTrue())
+ Expect(isDirOrSymlinkToDir("tests", dir)).To(BeTrue())
})
It("returns true for symlinks to dirs", func() {
dir, _ := os.Stat("tests/fixtures/symlink2dir")
- Expect(IsDirOrSymlinkToDir("tests/fixtures", dir)).To(BeTrue())
+ Expect(isDirOrSymlinkToDir("tests/fixtures", dir)).To(BeTrue())
})
It("returns false for files", func() {
dir, _ := os.Stat("tests/fixtures/test.mp3")
- Expect(IsDirOrSymlinkToDir("tests/fixtures", dir)).To(BeFalse())
+ Expect(isDirOrSymlinkToDir("tests/fixtures", dir)).To(BeFalse())
})
It("returns false for symlinks to files", func() {
dir, _ := os.Stat("tests/fixtures/symlink")
- Expect(IsDirOrSymlinkToDir("tests/fixtures", dir)).To(BeFalse())
+ Expect(isDirOrSymlinkToDir("tests/fixtures", dir)).To(BeFalse())
})
})
- Describe("IsDirIgnored", func() {
+ Describe("isDirIgnored", func() {
baseDir := filepath.Join("tests", "fixtures")
It("returns false for normal dirs", func() {
dir, _ := os.Stat(filepath.Join(baseDir, "empty_folder"))
- Expect(IsDirIgnored(baseDir, dir)).To(BeFalse())
+ Expect(isDirIgnored(baseDir, dir)).To(BeFalse())
})
It("returns true when folder contains .ndignore file", func() {
dir, _ := os.Stat(filepath.Join(baseDir, "ignored_folder"))
- Expect(IsDirIgnored(baseDir, dir)).To(BeTrue())
+ Expect(isDirIgnored(baseDir, dir)).To(BeTrue())
})
})
})