Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move watcher init to doWatcherLoop and implement -reloaddirs #2871

Merged
merged 5 commits into from
Sep 6, 2023

Conversation

haukened
Copy link
Contributor

@haukened haukened commented Aug 29, 2023

Description

In investigating #2829 i found that the *fsnotify.Watcher was only passed to a single function doWatcherLoop but the f.ReloadDirs wasn't parsed until inside the doWatcherLoop.

This PR moves the definition into doWatcherLoop to prevent unnecessary passing of the object, and implemented adding the -reloaddirs flag to the watcher. To prevent over-subscribing the watcher, i made the intentional choice not to make the watch recursive (like the main folder is), instead opting to explicitly watch only the directories specified by the user.

Fixes #2829

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested using the steps outlined in #2829 to confirm resolution:

Output noted that the directory was being watched:

Using DevServer URL: http://localhost:34115
Using Frontend DevServer URL: http://localhost:5173/
Using reload debounce setting of 100 milliseconds
Watching (sub)/directory: /tmp/myproject/gui
Watching (sub)/directory: /tmp/myproject/common

wails-dev binary built from source noticed the change in outside directory, and restarted:

[Rebuild triggered] files updated
 • Generating bindings: 
Done.
>  • Compiling application: 
  • Windows
  • macOS
  • Linux

Test Configuration

╭─david@arch /tmp/myproject/common  
╰─➤  wails doctor
Wails CLI v2.5.1

 SUCCESS  Done.                                                                                                                                             

# System

OS           | Arch Linux
Version      | Unknown   
ID           | arch      
Go Version   | go1.21.0  
Platform     | linux     
Architecture | amd64     

# Wails

Version         | v2.5.1
Package Manager | pacman

# Dependencies

Dependency | Package Name | Status    | Version    
*docker    | docker       | Installed | 1:24.0.5-1 
gcc        | gcc          | Installed | 13.2.1-3   
libgtk-3   | gtk3         | Installed | 1:3.24.38-1
libwebkit  | webkit2gtk   | Installed | 2.40.5-1   
npm        | npm          | Installed | 9.8.1-1    
pkg-config | pkgconf      | Installed | 1.8.1-1    
* - Optional Dependency

# Diagnosis

Your system is ready for Wails development!

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@leaanthony
Copy link
Member

@haukened - Any chance you could fix the conflict? Your other PR caused it 😅

@haukened
Copy link
Contributor Author

@haukened - Any chance you could fix the conflict? Your other PR caused it 😅

Nothing like conflicts in the changelog! 😂😂

@haukened
Copy link
Contributor Author

@leaanthony good to go now

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! 🙏

@leaanthony leaanthony merged commit 069fe18 into wailsapp:master Sep 6, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-reloaddirs option does not work
2 participants