@ -480,23 +480,19 @@ func Download(ctx *context.Context) {
aReq := archiver_service . DeriveRequestFrom ( ctx , uri )
aReq := archiver_service . DeriveRequestFrom ( ctx , uri )
downloadName := ctx . Repo . Repository . Name + "-" + aReq . GetArchiveName ( )
downloadName := ctx . Repo . Repository . Name + "-" + aReq . GetArchiveName ( )
if aReq . IsComplete ( ) {
if ! aReq . IsComplete ( ) {
ctx . ServeFile ( aReq . GetArchivePath ( ) , downloadName )
aReq = archiver_service . ArchiveRepository ( aReq )
} else {
archiver_service . LockQueue ( )
// We'll wait up to two seconds for the request to be satisfied, before we just return
for ! aReq . IsComplete ( ) {
// a 200 Accepted to indicate that we're processing.
archiver_service . WaitForCompletion ( )
archiver_service . ArchiveRepository ( aReq )
timeout := time . Now ( ) . Add ( 2 * time . Second )
for {
if aReq . IsComplete ( ) || time . Now ( ) . After ( timeout ) {
break
}
}
archiver_service . UnlockQueue ( )
}
}
if aReq . IsComplete ( ) {
if aReq . IsComplete ( ) {
ctx . ServeFile ( aReq . GetArchivePath ( ) , downloadName )
ctx . ServeFile ( aReq . GetArchivePath ( ) , downloadName )
} else {
} else {
ctx . Error ( 202 , "Request accepted, processing archive." )
ctx . Error ( 404 )
}
}
}
}
}
@ -513,7 +509,7 @@ func InitiateDownload(ctx *context.Context) {
complete := aReq . IsComplete ( )
complete := aReq . IsComplete ( )
if ! complete {
if ! complete {
archiver_service . ArchiveRepository ( aReq )
aReq = a rchiver_service . ArchiveRepository ( aReq )
// As with the standard Download, we'll wait up to two seconds for the request
// As with the standard Download, we'll wait up to two seconds for the request
// to be completed. The difference is that we'll never download the file from a POST
// to be completed. The difference is that we'll never download the file from a POST
// request, only indicate the current status. If we did manage to complete the request
// request, only indicate the current status. If we did manage to complete the request