Skip to content

Commit 0732516

Browse files
author
gentele
committed
Merge branch 'issue-233' of https://github.com/covexo/devspace into issue-233
2 parents f85d968 + 494d2bc commit 0732516

2 files changed

Lines changed: 40 additions & 29 deletions

File tree

cmd/reset.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,14 @@ func (cmd *ResetCmd) Run(cobraCmd *cobra.Command, args []string) {
171171
func (cmd *ResetCmd) determineResetExtent() {
172172
config := configutil.GetConfig(false)
173173

174-
cmd.flags.deleteDevspaceFolder = true
175174
cmd.flags.deleteRelease = true
176175

176+
cmd.flags.deleteDevspaceFolder = *stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{
177+
Question: "Should the .devspace folder be removed? (y/n)",
178+
DefaultValue: "y",
179+
ValidationRegexPattern: "^(y|n)$",
180+
}) == "y"
181+
177182
cmd.flags.deleteDockerfile = *stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{
178183
Question: "Should the Dockerfile be removed? (y/n)",
179184
DefaultValue: "y",

pkg/devspace/sync/sync_config.go

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (s *SyncConfig) initialSync() error {
268268
}
269269
s.fileIndex.fileMapMutex.Unlock()
270270

271-
err = s.diffServerClient(s.WatchPath, &localChanges, fileMapClone)
271+
err = s.diffServerClient(s.WatchPath, &localChanges, fileMapClone, false)
272272
if err != nil {
273273
return errors.Trace(err)
274274
}
@@ -292,7 +292,7 @@ func (s *SyncConfig) initialSync() error {
292292
return nil
293293
}
294294

295-
func (s *SyncConfig) diffServerClient(filepath string, sendChanges *[]*fileInformation, downloadChanges map[string]*fileInformation) error {
295+
func (s *SyncConfig) diffServerClient(filepath string, sendChanges *[]*fileInformation, downloadChanges map[string]*fileInformation, dontSend bool) error {
296296
relativePath := getRelativeFromFullPath(filepath, s.WatchPath)
297297
stat, err := os.Lstat(filepath)
298298

@@ -319,34 +319,34 @@ func (s *SyncConfig) diffServerClient(filepath string, sendChanges *[]*fileInfor
319319
}
320320
s.fileIndex.fileMapMutex.Unlock()
321321

322-
return nil
322+
dontSend = true
323323
}
324324
}
325325

326-
s.fileIndex.fileMapMutex.Lock()
327-
shouldUpload := shouldUpload(relativePath, stat, s, true)
328-
s.fileIndex.fileMapMutex.Unlock()
329-
330-
if shouldUpload == false {
331-
return nil
332-
}
333-
334326
if stat.IsDir() {
335-
return s.diffDir(filepath, stat, sendChanges, downloadChanges)
327+
return s.diffDir(filepath, stat, sendChanges, downloadChanges, dontSend)
336328
}
337329

338-
// Add file to upload
339-
*sendChanges = append(*sendChanges, &fileInformation{
340-
Name: relativePath,
341-
Mtime: roundMtime(stat.ModTime()),
342-
Size: stat.Size(),
343-
IsDirectory: false,
344-
})
330+
if dontSend == false {
331+
s.fileIndex.fileMapMutex.Lock()
332+
shouldUpload := shouldUpload(relativePath, stat, s, true)
333+
s.fileIndex.fileMapMutex.Unlock()
334+
335+
if shouldUpload {
336+
// Add file to upload
337+
*sendChanges = append(*sendChanges, &fileInformation{
338+
Name: relativePath,
339+
Mtime: roundMtime(stat.ModTime()),
340+
Size: stat.Size(),
341+
IsDirectory: false,
342+
})
343+
}
344+
}
345345

346346
return nil
347347
}
348348

349-
func (s *SyncConfig) diffDir(filepath string, stat os.FileInfo, sendChanges *[]*fileInformation, downloadChanges map[string]*fileInformation) error {
349+
func (s *SyncConfig) diffDir(filepath string, stat os.FileInfo, sendChanges *[]*fileInformation, downloadChanges map[string]*fileInformation, dontSend bool) error {
350350
relativePath := getRelativeFromFullPath(filepath, s.WatchPath)
351351
files, err := ioutil.ReadDir(filepath)
352352

@@ -355,17 +355,23 @@ func (s *SyncConfig) diffDir(filepath string, stat os.FileInfo, sendChanges *[]*
355355
return nil
356356
}
357357

358-
if len(files) == 0 && relativePath != "" {
359-
*sendChanges = append(*sendChanges, &fileInformation{
360-
Name: relativePath,
361-
Mtime: roundMtime(stat.ModTime()),
362-
Size: stat.Size(),
363-
IsDirectory: true,
364-
})
358+
if len(files) == 0 && relativePath != "" && dontSend == false {
359+
s.fileIndex.fileMapMutex.Lock()
360+
shouldUpload := shouldUpload(relativePath, stat, s, true)
361+
s.fileIndex.fileMapMutex.Unlock()
362+
363+
if shouldUpload {
364+
*sendChanges = append(*sendChanges, &fileInformation{
365+
Name: relativePath,
366+
Mtime: roundMtime(stat.ModTime()),
367+
Size: stat.Size(),
368+
IsDirectory: true,
369+
})
370+
}
365371
}
366372

367373
for _, f := range files {
368-
if err := s.diffServerClient(path.Join(filepath, f.Name()), sendChanges, downloadChanges); err != nil {
374+
if err := s.diffServerClient(path.Join(filepath, f.Name()), sendChanges, downloadChanges, dontSend); err != nil {
369375
return errors.Trace(err)
370376
}
371377
}

0 commit comments

Comments
 (0)