more stuff to Stream
This commit is contained in:
parent
b8ea9750bf
commit
93f416403e
1 changed files with 12 additions and 5 deletions
17
stream.go
17
stream.go
|
@ -58,12 +58,19 @@ func (s Stream) SaveStreamInstant(URL string, img []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if swap {
|
if swap {
|
||||||
previousStreamInstantPath := filepath.Join(streamStoreDir, "previous.jpg")
|
s.SwapInstants(s.GetPreviousInstantPath(), s.GetCurrentInstantPath(), s.GetNextInstantPath())
|
||||||
nextStreamInstantPath := currentStreamInstantPath
|
}
|
||||||
currentStreamInstantPath = filepath.Join(streamStoreDir, "current.jpg")
|
}
|
||||||
|
|
||||||
err = os.Rename(currentStreamInstantPath, previousStreamInstantPath)
|
// SwapInstants swaps the file location, first current -> previous and then next -> current
|
||||||
err = os.Rename(nextStreamInstantPath, currentStreamInstantPath)
|
func (s Stream) SwapInstants(previous string, current string, next string) {
|
||||||
|
err := os.Rename(current, previous)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Couldn't copy current image instant to previous image instant")
|
||||||
|
}
|
||||||
|
err = os.Rename(next, current)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Couldn't copy next image instant to current image instant")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue