mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
fix for dev file watching missing some file updates due to platform oddities (#1946)
This commit is contained in:
parent
eee6797907
commit
eae90df323
1 changed files with 27 additions and 11 deletions
|
|
@ -574,7 +574,19 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
|||
case err := <-watcher.Errors:
|
||||
LogDarkYellow(err.Error())
|
||||
case item := <-watcher.Events:
|
||||
// Check for file writes
|
||||
isEligibleFile := func(fileName string) bool {
|
||||
// Iterate all file patterns
|
||||
ext := filepath.Ext(fileName)
|
||||
if ext != "" {
|
||||
ext = ext[1:]
|
||||
if _, exists := extensionsThatTriggerARebuild[ext]; exists {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Handle write operations
|
||||
if item.Op&fsnotify.Write == fsnotify.Write {
|
||||
// Ignore directories
|
||||
itemName := item.Name
|
||||
|
|
@ -582,15 +594,10 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
|||
continue
|
||||
}
|
||||
|
||||
// Iterate all file patterns
|
||||
ext := filepath.Ext(itemName)
|
||||
if ext != "" {
|
||||
ext = ext[1:]
|
||||
if _, exists := extensionsThatTriggerARebuild[ext]; exists {
|
||||
rebuild = true
|
||||
timer.Reset(interval)
|
||||
continue
|
||||
}
|
||||
if isEligibleFile(itemName) {
|
||||
rebuild = true
|
||||
timer.Reset(interval)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, reloadDir := range dirsThatTriggerAReload {
|
||||
|
|
@ -606,7 +613,8 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
|||
|
||||
timer.Reset(interval)
|
||||
}
|
||||
// Check for new directories
|
||||
|
||||
// Handle new fs entries that are created
|
||||
if item.Op&fsnotify.Create == fsnotify.Create {
|
||||
// If this is a folder, add it to our watch list
|
||||
if fs.DirExists(item.Name) {
|
||||
|
|
@ -618,6 +626,14 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
|||
}
|
||||
LogGreen("Added new directory to watcher: %s", item.Name)
|
||||
}
|
||||
} else if isEligibleFile(item.Name) {
|
||||
// Handle creation of new file.
|
||||
// Note: On some platforms an update to a file is represented as
|
||||
// REMOVE -> CREATE instead of WRITE, so this is not only new files
|
||||
// but also updates to existing files
|
||||
rebuild = true
|
||||
timer.Reset(interval)
|
||||
continue
|
||||
}
|
||||
}
|
||||
case <-timer.C:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue