MCPcopy Index your code
hub / github.com/devspace-sh/devspace / deltaState

Method deltaState

pkg/devspace/sync/initial.go:194–271  ·  view source on GitHub ↗
(remoteState map[string]*FileInformation, localState map[string]*FileInformation, strategy latest.InitialSyncStrategy)

Source from the content-addressed store, hash-verified

192}
193
194func (i *initialSyncer) deltaState(remoteState map[string]*FileInformation, localState map[string]*FileInformation, strategy latest.InitialSyncStrategy) ([]*FileInformation, error) {
195 changes := make([]*FileInformation, 0, 1024)
196 for relativePath, stat := range localState {
197 absPath := path.Join(i.o.LocalPath, relativePath)
198 ignore := false
199
200 // Exclude changes on the upload exclude list
201 if i.o.UploadIgnoreMatcher != nil {
202 if i.o.UploadIgnoreMatcher.Matches(relativePath, stat.IsDirectory) {
203 i.o.FileIndex.Lock()
204 // Add to file map and prevent download if local file is newer than the remote one
205 if i.o.FileIndex.fileMap[relativePath] != nil {
206 if strategy == latest.InitialSyncStrategyPreferLocal || (strategy == latest.InitialSyncStrategyPreferNewest && i.o.FileIndex.fileMap[relativePath].Mtime < stat.Mtime) {
207 // Add it to the fileMap
208 i.o.FileIndex.Set(stat)
209
210 delete(remoteState, relativePath)
211 }
212 }
213
214 i.o.FileIndex.Unlock()
215 ignore = true
216 }
217 }
218
219 // Check for symlinks
220 if !ignore && stat.ResolvedLink {
221 _, err := i.o.AddSymlink(relativePath, absPath)
222 if err != nil {
223 return nil, err
224 }
225
226 i.o.Log.Infof("Symlink found at %s", absPath)
227 }
228
229 // Check if stat is somehow not there
230 if i.o.IgnoreMatcher != nil && !i.o.IgnoreMatcher.RequireFullScan() && i.o.IgnoreMatcher.Matches(relativePath, stat.IsDirectory) {
231 continue
232 }
233
234 if stat.IsDirectory {
235 // we don't need to recreate a directory that already exists locally
236 delete(remoteState, relativePath)
237
238 // should this directory be added?
239 if !ignore && stat.Files == 0 {
240 i.o.FileIndex.Lock()
241 action := i.decide(stat, strategy)
242 i.o.FileIndex.Unlock()
243
244 // This can be only uploadAction or noAction, since this is a directory
245 if action == uploadAction {
246 changes = append(changes, stat)
247 }
248 }
249
250 continue
251 }

Callers 1

CalculateDeltaMethod · 0.95

Calls 8

decideMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80
AddSymlinkMethod · 0.80
MatchesMethod · 0.65
RequireFullScanMethod · 0.65
SetMethod · 0.45
InfofMethod · 0.45

Tested by

no test coverage detected