/
storage.go
39 lines (35 loc) · 1.14 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package server
import (
"github.com/cyclopcam/cyclops/pkg/log"
"github.com/cyclopcam/cyclops/server/eventdb"
"github.com/cyclopcam/cyclops/server/util"
)
func (s *Server) SetPermanentStoragePath(root string) error {
if db, err := eventdb.NewEventDB(log.NewPrefixLogger(s.Log, "PermEventDB"), root); err != nil {
return err
} else {
s.permanentEvents = db
return nil
}
}
func (s *Server) SetRecentEventStoragePath(root string) error {
if db, err := eventdb.NewEventDB(log.NewPrefixLogger(s.Log, "RecentEventDB"), root); err != nil {
return err
} else {
s.recentEvents = db
return nil
}
}
// We don't want temp files to be on the videos dir, because the videos are likely to be
// stored on a USB flash drive, and this could cause the temp file to get written to disk,
// when we don't actually want that. We just want it as swap space... i.e. only written to disk
// if we run out of RAM.
func (s *Server) SetTempFilePath(tempFilePath string) error {
s.Log.Infof("Temp file path '%v'", tempFilePath)
if tempFiles, err := util.NewTempFiles(tempFilePath, s.Log); err != nil {
return err
} else {
s.TempFiles = tempFiles
}
return nil
}