Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not loose downloaded files in mirror update #676

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions cmd/mirror_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
pushError(e)
continue
}

task.Finished = true
case <-abort:
return
}
Expand All @@ -208,10 +210,6 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {

context.Progress().ShutdownBar()

if len(errors) > 0 {
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
}

err = context.ReOpenDatabase()
if err != nil {
return fmt.Errorf("unable to update: %s", err)
Expand All @@ -226,6 +224,10 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {

task := &queue[idx]

if !task.Finished {
continue
}

// and import it back to the pool
task.File.PoolPath, err = context.PackagePool().Import(task.TempDownPath, task.File.Filename, &task.File.Checksums, true, context.CollectionFactory().ChecksumCollection())
if err != nil {
Expand All @@ -247,6 +249,10 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {

context.Progress().ShutdownBar()

if len(errors) > 0 {
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
}

repo.FinalizeDownload(context.CollectionFactory(), context.Progress())
err = context.CollectionFactory().RemoteRepoCollection().Update(repo)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions deb/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ type PackageDownloadTask struct {
File *PackageFile
Additional []PackageDownloadTask
TempDownPath string
Finished bool
}

// DownloadList returns list of missing package files for download in format
Expand Down