Skip to content

Commit

Permalink
Fixes bug to actually handle "/" in source name
Browse files Browse the repository at this point in the history
Does require legacy servers to fix log, stage, and incoming
paths to accommodate "/" -> "--" in source naming before
applying this updated version.
  • Loading branch information
sbeus committed Sep 27, 2023
1 parent b238287 commit 930632c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions main/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"

"code.arm.gov/dataflow/sts"
"code.arm.gov/dataflow/sts/control"
Expand Down Expand Up @@ -65,12 +66,13 @@ func (a *serverApp) init() (err error) {
}
}
newStage := func(source string) sts.GateKeeper {
sourcePathReady := strings.ReplaceAll(source, string(os.PathSeparator), "--")
return stage.New(
source,
filepath.Join(dirs.Stage, source),
filepath.Join(dirs.Final, source),
filepath.Join(dirs.Stage, sourcePathReady),
filepath.Join(dirs.Final, sourcePathReady),
log.NewFileIO(
filepath.Join(dirs.LogIn, source),
filepath.Join(dirs.LogIn, sourcePathReady),
nil, nil, !a.conf.PermitLogBuf),
dispatcher,
)
Expand All @@ -79,11 +81,6 @@ func (a *serverApp) init() (err error) {
var stager sts.GateKeeper
stagers := make(map[string]sts.GateKeeper)

// It is possible for a source to include a "/" in its name. In that case,
// on restart, the wrong "stager" will be started and recovered. Any files
// recovered will be logged in a different place. It means the stager that
// gets properly started later when data comes in will not know about these
// logs and duplicates could be received.
nodes, err := os.ReadDir(dirs.Stage)
if err != nil {
return
Expand Down

0 comments on commit 930632c

Please sign in to comment.