File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 "os"
88 "path/filepath"
99 "strings"
10+ "sync"
1011 "time"
1112)
1213
@@ -67,19 +68,27 @@ func (fr *findReplace) WalkDir(f *File) {
6768// complete, the file is renamed (if necessary) since no subsequent operations
6869// will need to access it again.
6970func (fr * findReplace ) HandleFile (f * File ) {
71+ var wg sync.WaitGroup
72+
7073 // If file is a directory, recurse immediately (depth-first).
7174 if f .Info ().IsDir () {
7275 // Ignore certain directories
7376 if f .Base () == ".git" {
7477 return
7578 }
7679
77- fr .WalkDir (f )
80+ wg .Add (1 )
81+ go func () {
82+ defer wg .Done ()
83+ fr .WalkDir (f )
84+ }()
7885 } else {
7986 // Replace the contents of regular files
8087 fr .ReplaceContents (f )
8188 }
8289
90+ wg .Wait () // for (potentially recursive) WalkDir calls to return
91+
8392 // Rename the file now that we're otherwise done with it
8493 fr .RenameFile (f )
8594}
You can’t perform that action at this time.
0 commit comments