Skip to content

Commit

Permalink
Do not check destinations or files for output consumer null
Browse files Browse the repository at this point in the history
  • Loading branch information
tempusfrangit committed Dec 15, 2023
1 parent 5eceeda commit c02c2b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
28 changes: 17 additions & 11 deletions cmd/multifile/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bufio"
"errors"
"fmt"
"github.com/replicate/pget/pkg/config"
"github.com/spf13/viper"
"io"
"io/fs"
"os"
Expand Down Expand Up @@ -86,18 +88,22 @@ func parseManifest(file io.Reader) (pget.Manifest, error) {
return nil, err
}

err = checkSeenDests(seenDests, dest, urlString)
if err != nil {
return nil, err
}

seenDests[dest] = urlString

err = cli.EnsureDestinationNotExist(dest)
if err != nil {
return nil, err
// THIS IS A BODGE - FIX ME MOVE THESE THINGS TO PGET
// and make the consumer responsible for knowing if this
// is allowed/not allowed/etc
consumer := viper.GetString(config.OptOutputConsumer)
if consumer != config.ConsumerNull {
err = checkSeenDests(seenDests, dest, urlString)
if err != nil {
return nil, err
}
seenDests[dest] = urlString

err = cli.EnsureDestinationNotExist(dest)
if err != nil {
return nil, err
}
}

schemeHost, err := client.GetSchemeHostKey(urlString)
if err != nil {
return nil, fmt.Errorf("error parsing url %s: %w", urlString, err)
Expand Down
8 changes: 6 additions & 2 deletions cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ func runRootCMD(cmd *cobra.Command, args []string) error {
Str("minimum_chunk_size", viper.GetString(config.OptMinimumChunkSize)).
Msg("Initiating")

if err := cli.EnsureDestinationNotExist(dest); err != nil {
return err
// OMG BODGE FIX THIS
consumer := viper.GetString(config.OptOutputConsumer)
if consumer != config.ConsumerNull {
if err := cli.EnsureDestinationNotExist(dest); err != nil {
return err
}
}
if err := rootExecute(cmd.Context(), urlString, dest); err != nil {
return err
Expand Down

0 comments on commit c02c2b4

Please sign in to comment.