2022-08-31 19:56:06 -04:00
|
|
|
package transcoder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"path/filepath"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Repository struct {
|
|
|
|
basePath string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRepository(path string) *Repository {
|
|
|
|
// make sure repository base directory exists
|
|
|
|
create_repo_dir(path)
|
|
|
|
|
|
|
|
// make sure the ingest, archive, and output directories exist
|
|
|
|
subDirs := []string{"ingest", "archive", "output"}
|
|
|
|
for _, d := range subDirs {
|
|
|
|
subPath := filepath.Join(path, d)
|
|
|
|
create_repo_dir(subPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
r := new(Repository)
|
|
|
|
r.basePath = path
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func create_repo_dir(path string) {
|
|
|
|
_, err := os.Stat(path)
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
log.Printf("Creating directory %s.\n", path)
|
2022-08-31 20:16:21 -04:00
|
|
|
os.Mkdir(path, 0755)
|
2022-08-31 19:56:06 -04:00
|
|
|
} else {
|
|
|
|
log.Printf("Directory %s already exists.\n", path)
|
|
|
|
}
|
|
|
|
}
|