feat(editor): wait for ready file and rename to doEditor.go

This commit is contained in:
Castor Regex 2025-08-25 11:49:30 -05:00 committed by Jeff Carr
parent f5b923f180
commit 4f215037a1
1 changed files with 29 additions and 1 deletions

View File

@ -5,9 +5,37 @@ import (
"os"
"os/exec"
"strings"
"time"
"go.wit.com/log"
)
func doEditor() (string, error) {
func doEditor() error {
for {
filename, err := doEditorOnce()
if err != nil {
return err
}
log.Info("filename:", filename)
for {
_, err := os.Stat("/tmp/regex.ready")
if err == nil {
break
}
time.Sleep(100 * time.Millisecond)
}
// read in regex.ready exists (should be SessionID)
// Println session ID
content, err := ioutil.ReadFile("/tmp/regex.ready")
if err != nil {
log.Error(err)
}
log.Infof("SessionID: %s", string(content))
}
}
func doEditorOnce() (string, error) {
// Create a temporary file
tmpfile, err := ioutil.TempFile("", "regex-*.txt")
if err != nil {