downloaded files goes to download
This commit is contained in:
parent
d636d963ff
commit
9e506145a8
20
cmd/fetch.go
20
cmd/fetch.go
@ -25,7 +25,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Check if files already exist
|
// TODO: Check if files already exist
|
||||||
// Fetch release files, verify, put in datastore under ${datastore}/releases
|
// Fetch release files, verify, put in datastore under ${datastore}/download, then extract into ${datastore}/releases
|
||||||
// Only support http
|
// Only support http
|
||||||
func fetchRelease(release string, proto string, arch string, datastore string) {
|
func fetchRelease(release string, proto string, arch string, datastore string) {
|
||||||
var ds Datastore
|
var ds Datastore
|
||||||
@ -47,24 +47,24 @@ func fetchRelease(release string, proto string, arch string, datastore string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check datastore have a releases dataset, and it is mounted
|
// Check datastore have a download dataset, and it is mounted
|
||||||
releaseDsName := fmt.Sprintf("%s/releases", ds.ZFSDataset)
|
downloadDsName := fmt.Sprintf("%s/download", ds.ZFSDataset)
|
||||||
releaseDsMountPoint := fmt.Sprintf("%s/releases", ds.Mountpoint)
|
downloadDsMountPoint := fmt.Sprintf("%s/download", ds.Mountpoint)
|
||||||
exist, err := doZfsDatasetExist(releaseDsName)
|
exist, err := doZfsDatasetExist(downloadDsName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error accessing dataset %s: %v\n", releaseDsName, err)
|
fmt.Printf("Error accessing dataset %s: %v\n", downloadDsName, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if false == exist {
|
if false == exist {
|
||||||
// Then create dataset
|
// Then create dataset
|
||||||
if err := createZfsDataset(releaseDsName, releaseDsMountPoint, "lz4"); err != nil {
|
if err := createZfsDataset(downloadDsName, downloadDsMountPoint, "lz4"); err != nil {
|
||||||
fmt.Printf("Error creating dataset %s: %v\n", releaseDsName, err)
|
fmt.Printf("Error creating dataset %s: %v\n", downloadDsName, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create XX.X-RELEASE directory if necessary
|
// Create XX.X-RELEASE directory if necessary
|
||||||
fileDir := fmt.Sprintf("%s/%s-RELEASE", releaseDsMountPoint, release)
|
fileDir := fmt.Sprintf("%s/%s-RELEASE", downloadDsMountPoint, release)
|
||||||
_, err = os.Stat(fileDir)
|
_, err = os.Stat(fileDir)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
if err := os.Mkdir(fileDir, 0755); err != nil {
|
if err := os.Mkdir(fileDir, 0755); err != nil {
|
||||||
@ -113,6 +113,8 @@ func fetchRelease(release string, proto string, arch string, datastore string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Extract download/$RELEASE/files to releases/$RELEASE/
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchHTTPFile(baseUrl, fileName, storeDir string, checksum []byte) error {
|
func fetchHTTPFile(baseUrl, fileName, storeDir string, checksum []byte) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user