Add publish output progress counting remaining number of packages

This commit is contained in:
Oliver Sauder
2018-05-17 15:44:49 +02:00
committed by Lorenzo Bolla
parent 3cd168c44d
commit f09a273ad7
15 changed files with 106 additions and 27 deletions

View File

@@ -59,6 +59,7 @@ func apiMirrorsCreate(c *gin.Context) {
Keyrings []string
DownloadSources bool
DownloadUdebs bool
DownloadInstaller bool
FilterWithDeps bool
SkipComponentCheck bool
IgnoreSignatures bool
@@ -92,7 +93,7 @@ func apiMirrorsCreate(c *gin.Context) {
}
repo, err := deb.NewRemoteRepo(b.Name, b.ArchiveURL, b.Distribution, b.Components, b.Architectures,
b.DownloadSources, b.DownloadUdebs)
b.DownloadSources, b.DownloadUdebs, b.DownloadInstaller)
if err != nil {
c.AbortWithError(400, fmt.Errorf("unable to create mirror: %s", err))
@@ -289,7 +290,6 @@ func apiMirrorsUpdate(c *gin.Context) {
IgnoreSignatures bool
ForceUpdate bool
SkipExistingPackages bool
MaxTries int
}
collectionFactory := context.NewCollectionFactory()
@@ -364,11 +364,7 @@ func apiMirrorsUpdate(c *gin.Context) {
}
}
if b.MaxTries <= 0 {
b.MaxTries = 1
}
err = remote.DownloadPackageIndexes(out, downloader, collectionFactory, b.SkipComponentCheck, b.MaxTries)
err = remote.DownloadPackageIndexes(out, downloader, verifier, collectionFactory, b.SkipComponentCheck)
if err != nil {
return fmt.Errorf("unable to update: %s", err)
}
@@ -388,7 +384,7 @@ func apiMirrorsUpdate(c *gin.Context) {
}
queue, downloadSize, err := remote.BuildDownloadQueue(context.PackagePool(), collectionFactory.PackageCollection(),
collectionFactory.ChecksumCollection(), b.SkipExistingPackages)
collectionFactory.ChecksumCollection(nil), b.SkipExistingPackages)
if err != nil {
return fmt.Errorf("unable to update: %s", err)
}
@@ -490,8 +486,7 @@ func apiMirrorsUpdate(c *gin.Context) {
remote.PackageURL(task.File.DownloadURL()).String(),
task.TempDownPath,
&task.File.Checksums,
b.IgnoreChecksums,
b.MaxTries)
b.IgnoreChecksums)
if e != nil {
pushError(e)
continue
@@ -521,7 +516,7 @@ func apiMirrorsUpdate(c *gin.Context) {
}
// and import it back to the pool
task.File.PoolPath, err = context.PackagePool().Import(task.TempDownPath, task.File.Filename, &task.File.Checksums, true, collectionFactory.ChecksumCollection())
task.File.PoolPath, err = context.PackagePool().Import(task.TempDownPath, task.File.Filename, &task.File.Checksums, true, collectionFactory.ChecksumCollection(nil))
if err != nil {
return fmt.Errorf("unable to import file: %s", err)
}

View File

@@ -183,6 +183,14 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
taskName := fmt.Sprintf("Publish %s: %s", b.SourceKind, strings.Join(names, ", "))
task, conflictErr := runTaskInBackground(taskName, resources, func(out *task.Output, detail *task.Detail) error {
taskDetail := task.PublishDetail{
Detail: detail,
}
publishOutput := &task.PublishOutput{
Output: out,
PublishDetail: taskDetail,
}
if b.Origin != "" {
published.Origin = b.Origin
}
@@ -209,7 +217,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
return fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
}
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, out, b.ForceOverwrite)
err := published.Publish(context.PackagePool(), context, collectionFactory, signer, publishOutput, b.ForceOverwrite)
if err != nil {
return fmt.Errorf("unable to publish: %s", err)
}