Published persistence: save persisted when publishing.

This commit is contained in:
Andrey Smirnov
2014-01-16 23:04:22 +04:00
parent a8e6251a80
commit 33a8dcdacd
3 changed files with 311 additions and 4 deletions
+17 -1
View File
@@ -21,10 +21,15 @@ func aptlyPublishSnapshot(cmd *commander.Command, args []string) error {
var prefix string
if len(args) == 2 {
prefix = args[1]
if prefix == "." || prefix == "/" {
prefix = ""
}
} else {
prefix = ""
}
publishedCollecton := debian.NewPublishedRepoCollection(context.database)
snapshotCollection := debian.NewSnapshotCollection(context.database)
snapshot, err := snapshotCollection.ByName(name)
if err != nil {
@@ -67,10 +72,21 @@ func aptlyPublishSnapshot(cmd *commander.Command, args []string) error {
published := debian.NewPublishedRepo(prefix, distribution, component, context.architecturesList, snapshot)
duplicate := publishedCollecton.CheckDuplicate(published)
if duplicate != nil {
publishedCollecton.LoadComplete(duplicate, snapshotCollection)
return fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate)
}
packageCollection := debian.NewPackageCollection(context.database)
err = published.Publish(context.packageRepository, packageCollection, signer)
if err != nil {
return err
return fmt.Errorf("unable to publish: %s", err)
}
err = publishedCollecton.Add(published)
if err != nil {
return fmt.Errorf("unable to save to DB: %s", err)
}
if prefix != "" && !strings.HasSuffix(prefix, "/") {