(files []*FileInformation)
| 823 | } |
| 824 | |
| 825 | func (u *upstream) filterChanges(files []*FileInformation) ([]*FileInformation, error) { |
| 826 | alreadyUsed := map[string]bool{} |
| 827 | newChanges := make([]*FileInformation, 0, len(files)) |
| 828 | needCheck := []*FileInformation{} |
| 829 | |
| 830 | // filter them first |
| 831 | for _, f := range files { |
| 832 | if f.Size > largeFileSize { |
| 833 | u.sync.log.Debugf("Large file encountered at %s (%0.2f MB). Please try to avoid syncing large files as this will slow down DevSpace", u.getRelativeUpstreamPath(f.Name), float64(f.Size)/1024.0/1024.0) |
| 834 | } |
| 835 | |
| 836 | if alreadyUsed[f.Name] { |
| 837 | continue |
| 838 | } else if f.IsDirectory || u.sync.fileIndex.fileMap[f.Name] == nil || u.sync.fileIndex.fileMap[f.Name].Size != f.Size { |
| 839 | newChanges = append(newChanges, f) |
| 840 | alreadyUsed[f.Name] = true |
| 841 | continue |
| 842 | } else if f.Size == 0 { |
| 843 | alreadyUsed[f.Name] = true |
| 844 | continue |
| 845 | } |
| 846 | |
| 847 | alreadyUsed[f.Name] = true |
| 848 | needCheck = append(needCheck, f) |
| 849 | } |
| 850 | |
| 851 | // now compare crc32 hashes |
| 852 | if len(needCheck) > 0 { |
| 853 | u.sync.log.Debugf("Start hashing %d files", len(needCheck)) |
| 854 | defer u.sync.log.Debugf("Done hashing %d files", len(needCheck)) |
| 855 | |
| 856 | // cancel after 10 minutes |
| 857 | ctx, cancel := context.WithTimeout(u.sync.ctx, time.Minute*30) |
| 858 | defer cancel() |
| 859 | |
| 860 | // create done chan |
| 861 | done := make(chan error) |
| 862 | |
| 863 | // start remote hashing |
| 864 | remoteChecksums := make([]uint32, 0, len(needCheck)) |
| 865 | localChecksums := make([]uint32, 0, len(needCheck)) |
| 866 | go func() { |
| 867 | // send 1000 each time |
| 868 | batchSize := 1000 |
| 869 | for i := 0; i < len(needCheck); i += batchSize { |
| 870 | batch := make([]*remote.TouchPath, 0, batchSize) |
| 871 | for j := 0; j < batchSize; j++ { |
| 872 | if i+j >= len(needCheck) { |
| 873 | break |
| 874 | } |
| 875 | |
| 876 | change := needCheck[i+j] |
| 877 | u.sync.fileIndex.fileMap[change.Name].Mtime = change.Mtime |
| 878 | touchPath := &remote.TouchPath{ |
| 879 | Path: change.Name, |
| 880 | MtimeUnix: change.Mtime, |
| 881 | } |
| 882 | if !equalFilePermissions(u.sync.fileIndex.fileMap[change.Name].Mode, change.Mode) { |
no test coverage detected