downloaded files goes to download

This commit is contained in:
yo 2022-10-16 15:32:47 +02:00
parent d636d963ff
commit 9e506145a8

View File

@ -25,7 +25,7 @@ var (
)
// 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
func fetchRelease(release string, proto string, arch string, datastore string) {
var ds Datastore
@ -47,24 +47,24 @@ func fetchRelease(release string, proto string, arch string, datastore string) {
return
}
// Check datastore have a releases dataset, and it is mounted
releaseDsName := fmt.Sprintf("%s/releases", ds.ZFSDataset)
releaseDsMountPoint := fmt.Sprintf("%s/releases", ds.Mountpoint)
exist, err := doZfsDatasetExist(releaseDsName)
// Check datastore have a download dataset, and it is mounted
downloadDsName := fmt.Sprintf("%s/download", ds.ZFSDataset)
downloadDsMountPoint := fmt.Sprintf("%s/download", ds.Mountpoint)
exist, err := doZfsDatasetExist(downloadDsName)
if err != nil {
fmt.Printf("Error accessing dataset %s: %v\n", releaseDsName, err)
fmt.Printf("Error accessing dataset %s: %v\n", downloadDsName, err)
return
}
if false == exist {
// Then create dataset
if err := createZfsDataset(releaseDsName, releaseDsMountPoint, "lz4"); err != nil {
fmt.Printf("Error creating dataset %s: %v\n", releaseDsName, err)
if err := createZfsDataset(downloadDsName, downloadDsMountPoint, "lz4"); err != nil {
fmt.Printf("Error creating dataset %s: %v\n", downloadDsName, err)
return
}
}
// 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)
if os.IsNotExist(err) {
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 {