-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockbuffer.go
More file actions
executable file
·55 lines (44 loc) · 1.36 KB
/
blockbuffer.go
File metadata and controls
executable file
·55 lines (44 loc) · 1.36 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"os"
// import internal package
api "blockbuffer/internal/api"
fs "blockbuffer/internal/filesystem"
"blockbuffer/internal/io"
opts "blockbuffer/internal/settings"
)
func main() {
io.Logf("Watching: %s", io.Info, *opts.WatchDir)
io.Logf("Outputting to: %s", io.Info, *opts.OutputDir)
io.Logf("Uploading to: %s", io.Info, *opts.UploadDir)
// Ensure output directory exists
if _, err := os.Stat(*opts.OutputDir); os.IsNotExist(err) {
err := os.MkdirAll(*opts.OutputDir, 0755)
if err != nil {
io.Logf("Failed to create output directory: %v", io.Fatal, err)
}
}
// Ensure upload directory exists
if _, err := os.Stat(*opts.WatchDir); os.IsNotExist(err) {
err := os.MkdirAll(*opts.WatchDir, 0755)
if err != nil {
io.Logf("Failed to create upload directory: %v", io.Fatal, err)
}
}
if _, err := os.Stat(*opts.UploadDir); os.IsNotExist(err) {
err := os.MkdirAll(*opts.UploadDir, 0755)
if err != nil {
io.Logf("Failed to create upload directory: %v", io.Fatal, err)
}
}
// Scan input directory and queue files for conversion
go fs.ScanAndQueueFiles(*opts.WatchDir, *opts.OutputDir)
// Start watching the directory
go fs.WatchDirectory(*opts.WatchDir, *opts.OutputDir)
// Check the queue and process files
go fs.ProcessQueue()
// preprocess codecs
go api.InitializeCodecs()
// Start the server
api.StartServer()
}