Skip to content

Commit

Permalink
assign the stream function a temporary file during the information pa…
Browse files Browse the repository at this point in the history
…cket, and afterwards it is cleaned up
  • Loading branch information
rbisewski authored and samuell committed Sep 7, 2019
1 parent 8179b68 commit 938f0f0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/streamtosubstream.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package components

import (
"io/ioutil"
"os"
"github.com/scipipe/scipipe"
)

Expand Down Expand Up @@ -32,8 +34,15 @@ func (p *StreamToSubStream) OutSubStream() *scipipe.OutPort { return p.OutPort("
func (p *StreamToSubStream) Run() {
defer p.CloseAllOutPorts()

// create a temporary file, with a _scipipe prefix
tmpfile, err := ioutil.TempFile("", "_scipipe_tmp.")
if err != nil {
panic(err)
}
defer os.Remove(tmpfile.Name())

scipipe.Debug.Println("Creating new information packet for the substream...")
subStreamIP := scipipe.NewFileIP("")
subStreamIP := scipipe.NewFileIP(tmpfile.Name())
scipipe.Debug.Printf("Setting in-port of process %s to IP substream field\n", p.Name())
subStreamIP.SubStream = p.In()

Expand Down

0 comments on commit 938f0f0

Please sign in to comment.