From 06d90e70317cb2f7b8ecfd641d467a59b34eb862 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Thu, 31 Oct 2024 12:49:23 -0400 Subject: [PATCH] revert dynamic exclusion --- controllers/jobs/jobs.go | 13 ++++----- utils/get_exclusions.go | 58 ---------------------------------------- 2 files changed, 5 insertions(+), 66 deletions(-) delete mode 100644 utils/get_exclusions.go diff --git a/controllers/jobs/jobs.go b/controllers/jobs/jobs.go index 1ec228d..b75df10 100644 --- a/controllers/jobs/jobs.go +++ b/controllers/jobs/jobs.go @@ -46,7 +46,7 @@ func RunJob(job *store.Job, storeInstance *store.Store, token *store.Token) (*st smbPath, srcPath, "-o", - fmt.Sprintf("username=%s,password=%s", os.Getenv("DOMAIN_USER"), os.Getenv("DOMAIN_PASS")), + fmt.Sprintf("domain=%s,username=%s,password=%s,mfsymlinks,ro,mapchars", os.Getenv("DOMAIN"), os.Getenv("DOMAIN_USER"), os.Getenv("DOMAIN_PASS")), } mnt := exec.Command("mount", mountArgs...) @@ -69,13 +69,10 @@ func RunJob(job *store.Job, storeInstance *store.Store, token *store.Token) (*st "--repository", job.Store, "--change-detection-mode=metadata", - } - - exclusions, err := utils.GetExclusions(srcPath) - - for _, exclusion := range exclusions { - cmdArgs = append(cmdArgs, "--exclude") - cmdArgs = append(cmdArgs, exclusion) + "--exclude", + "System Volume Information", + "--exclude", + "$RECYCLE.BIN", } if job.Namespace != "" { diff --git a/utils/get_exclusions.go b/utils/get_exclusions.go deleted file mode 100644 index 204d7b9..0000000 --- a/utils/get_exclusions.go +++ /dev/null @@ -1,58 +0,0 @@ -package utils - -import ( - "io/fs" - "os" - "path/filepath" - "sync" - - "github.com/charlievieth/fastwalk" -) - -func GetExclusions(root string) ([]string, error) { - var excludedPaths []string - storeMutex := new(sync.Mutex) - - conf := fastwalk.Config{ - Follow: false, - } - - walkFn := func(path string, d fs.DirEntry, err error) error { - if err != nil { - var skipDir bool - if _, ok := err.(*os.PathError); ok { - info, err := os.Lstat(path) - if err != nil { - storeMutex.Lock() - excludedPaths = append(excludedPaths, convertToGlobPattern(path, root)) - storeMutex.Unlock() - } - - if info.Mode()&fs.ModeSymlink != 0 { - storeMutex.Lock() - excludedPaths = append(excludedPaths, convertToGlobPattern(path, root)) - storeMutex.Unlock() - } - } else { - storeMutex.Lock() - excludedPaths = append(excludedPaths, convertToGlobPattern(path, root)) - storeMutex.Unlock() - } - - if skipDir { - return filepath.SkipDir - } - return nil - } - return nil - } - - err := fastwalk.Walk(&conf, root, walkFn) - - return excludedPaths, err -} - -func convertToGlobPattern(path, root string) string { - relPath, _ := filepath.Rel(root, path) - return relPath -}