diff --git a/aegisub/build/BuildTasks/DependencyFetchers.fs b/aegisub/build/BuildTasks/DependencyFetchers.fs
index f5a360327..626eb3a01 100644
--- a/aegisub/build/BuildTasks/DependencyFetchers.fs
+++ b/aegisub/build/BuildTasks/DependencyFetchers.fs
@@ -95,6 +95,14 @@ type GitProject() =
this.Log.LogErrorFromException e
false
+let downloadArchive (url : String) unpackDest =
+ use wc = new Net.WebClient()
+ use downloadStream = wc.OpenRead url
+ use gzStream = new ICSharpCode.SharpZipLib.GZip.GZipInputStream(downloadStream)
+ use tarStream = new ICSharpCode.SharpZipLib.Tar.TarInputStream(gzStream)
+ use tarArchive = ICSharpCode.SharpZipLib.Tar.TarArchive.CreateInputTarArchive tarStream
+ tarArchive.ExtractContents unpackDest
+
type TarballProject() =
inherit Task()
@@ -111,13 +119,8 @@ type TarballProject() =
try IO.Directory.Delete(directory, true) with | :? IO.IOException -> ()
this.Log.LogMessage ("Downloading {0} {1} from {2}", project.ItemSpec, version, project.GetMetadata "Url")
- use wc = new Net.WebClient()
- use downloadStream = project.GetMetadata "Url" |> wc.OpenRead
- use gzStream = new ICSharpCode.SharpZipLib.GZip.GZipInputStream(downloadStream)
- use tarStream = new ICSharpCode.SharpZipLib.Tar.TarInputStream(gzStream)
- use tarArchive = ICSharpCode.SharpZipLib.Tar.TarArchive.CreateInputTarArchive tarStream
+ downloadArchive (project.GetMetadata "Url") (sprintf @"%s\.." directory)
- sprintf @"%s\.." directory |> tarArchive.ExtractContents
let dirname = project.GetMetadata "DirName"
if not <| String.IsNullOrWhiteSpace dirname
then IO.Directory.Move(dirname |> sprintf @"%s\..\%s" directory, directory)
@@ -138,3 +141,28 @@ type TarballProject() =
with e ->
this.Log.LogErrorFromException e
false
+
+type DownloadTgzFile() =
+ inherit Task()
+
+ member val Url = "" with get, set
+ member val Destination = "" with get, set
+ member val OutputFile = "" with get, set
+ member val Hash = "" with get, set
+
+ override this.Execute() =
+ let needsDownload =
+ try
+ use fs = IO.File.OpenRead this.OutputFile
+ let sha = new Security.Cryptography.SHA1Managed ()
+ let hash = sha.ComputeHash fs
+ BitConverter.ToString(hash).Replace("-", "") <> this.Hash
+ with | :? IO.IOException -> true
+
+ try
+ if needsDownload
+ then downloadArchive this.Url this.Destination
+ true
+ with e ->
+ this.Log.LogErrorFromException e
+ false
diff --git a/aegisub/build/deps/deps.vcxproj b/aegisub/build/deps/deps.vcxproj
index 3a370ede1..4d4d9cc84 100644
--- a/aegisub/build/deps/deps.vcxproj
+++ b/aegisub/build/deps/deps.vcxproj
@@ -64,6 +64,7 @@ Aegisub Project http://www.aegisub.org/
+
+
+
+
+