Skip to content

Commit

Permalink
Merge pull request #2 from Shinku-Chen/main
Browse files Browse the repository at this point in the history
添加自定义忽略文件的函数IsIgnoreFile
  • Loading branch information
tikazyq authored Aug 4, 2023
2 parents 855ecc4 + 7e8effc commit 2d9e66c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions seaweedfs_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (m *SeaweedFsManager) syncLocalToRemote(params seaweedFsManagerParams) (res
// compare local files with remote files and upload files with difference
for _, localFile := range localFiles {
// skip .git
if IsGitFile(localFile) {
if IsGitFile(localFile) || IsIgnoreFile(localFile) {
continue
}

Expand Down Expand Up @@ -568,7 +568,7 @@ func (m *SeaweedFsManager) syncRemoteToLocal(params seaweedFsManagerParams) (res
// compare local files with remote files and delete files absent on remote
for _, localFile := range localFiles {
// skip .git
if IsGitFile(localFile) {
if IsGitFile(localFile) || IsIgnoreFile(localFile) {
continue
}

Expand Down
14 changes: 14 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/crawlab-team/goseaweedfs"
"net/url"
"os"
"path/filepath"
"regexp"
"strings"
Expand All @@ -18,6 +19,19 @@ func IsGitFile(file goseaweedfs.FileInfo) (res bool) {
return res
}

func IsIgnoreFile(file goseaweedfs.FileInfo) (res bool) {
// skip .git
filerStr := os.Getenv("CRAWLAB_IS_IGNORE_FILE_FILER")
if filerStr == "" {
return false
}
res, err := regexp.MatchString(filerStr, file.Path)
if err != nil {
return false
}
return res
}

func getCollectionAndTtlFromArgs(args ...interface{}) (collection, ttl string) {
if len(args) > 0 {
collection = args[0].(string)
Expand Down

0 comments on commit 2d9e66c

Please sign in to comment.