compareRoots.go 816 B

1234567891011121314151617181920212223242526272829303132333435
  1. package hybridBackup
  2. import (
  3. "log"
  4. "path/filepath"
  5. "strings"
  6. )
  7. /*
  8. Compare roots
  9. This script compare the files between two folder recursively
  10. */
  11. //This function check which file exists in backup but not source drive
  12. func (t *BackupTask) compareRootPaths() ([]*RestorableFile, error) {
  13. results := []*RestorableFile{}
  14. //Check if the source and the backup disk exists
  15. fastWalk(t.DiskPath, func(filename string) error {
  16. rootAbs, _ := filepath.Abs(t.DiskPath)
  17. fileAbs, _ := filepath.Abs(filename)
  18. rootAbs = filepath.ToSlash(filepath.Clean(rootAbs))
  19. fileAbs = filepath.ToSlash(filepath.Clean(fileAbs))
  20. relPath := strings.ReplaceAll(fileAbs, rootAbs, "")
  21. assumedTargetPosition := filepath.Join(t.ParentPath, relPath)
  22. log.Println(assumedTargetPosition)
  23. return nil
  24. })
  25. return results, nil
  26. }