ce7cb702218693d08ea6d83464d2457c9250027c
This commit is contained in:
commit
34c5f8963c
1 changed files with 145336 additions and 0 deletions
36
services/minecraft/store.fsx
Normal file
36
services/minecraft/store.fsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
module Store
|
||||
|
||||
#r "/opt/fsi/packages/AWSSDK.Core.dll"
|
||||
#r "/opt/fsi/packages/AWSSDK.S3.dll"
|
||||
#load "bootstrap.fsx"
|
||||
|
||||
open System.IO
|
||||
open Amazon.Runtime
|
||||
open Amazon.S3
|
||||
open Amazon.S3.Model
|
||||
open Bootstrap
|
||||
|
||||
let connect auth =
|
||||
let credential name = File.ReadAllText(Path.Combine(auth, name))
|
||||
let config = AmazonS3Config(ServiceURL = "https://s3.quorate.internal", AuthenticationRegion = "us-east-1", ForcePathStyle = true)
|
||||
new AmazonS3Client(BasicAWSCredentials(credential "accesskey", credential "secretkey"), config)
|
||||
|
||||
let request key = GetObjectRequest(BucketName = "artifacts", Key = key)
|
||||
|
||||
let manifest (client: AmazonS3Client) key =
|
||||
use reply = client.GetObjectAsync(request ("minecraft/" + key)).GetAwaiter().GetResult()
|
||||
use reader = new StreamReader(reply.ResponseStream)
|
||||
reader.ReadToEnd()
|
||||
|
||||
let fetchObject (client: AmazonS3Client) key hash path =
|
||||
if not (File.Exists path) || digest path <> hash then
|
||||
let temporary = path + ".download"
|
||||
use reply = client.GetObjectAsync(request key).GetAwaiter().GetResult()
|
||||
use output = File.Create temporary
|
||||
reply.ResponseStream.CopyTo output
|
||||
output.Close()
|
||||
if digest temporary <> hash then invalidOp "download checksum differs"
|
||||
File.Move(temporary, path, true)
|
||||
|
||||
let fetch client key = fetchObject client ("minecraft/" + key)
|
||||
let saltatory client hash = fetchObject client ("saltatory/" + hash + ".jar") hash
|
||||
Loading…
Reference in a new issue