Skip to content

Commit

Permalink
fix remove need for dummy storage object
Browse files Browse the repository at this point in the history
  • Loading branch information
tarikozyurtt committed Jul 11, 2024
1 parent 70882e2 commit fd902a9
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions command/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,35 +125,33 @@ func (c Cat) Run(ctx context.Context) error {
printError(c.fullCommand, c.op, err)
return err
}
return c.processSingleObject(ctx, client, &storage.Object{URL: c.src})
return c.processSingleObject(ctx, client, c.src)
}

func (c Cat) processObjects(ctx context.Context, client *storage.S3, objectChan <-chan *storage.Object) error {
for obj := range objectChan {
if err := c.processSingleObject(ctx, client, obj); err != nil {
if obj.Err != nil {
printError(c.fullCommand, c.op, obj.Err)
return obj.Err
}

if obj.Type.IsDir() {
continue
}

err := c.processSingleObject(ctx, client, obj.URL)
if err != nil {
printError(c.fullCommand, c.op, err)
return err
}
}
return nil
}

func (c Cat) processSingleObject(ctx context.Context, client *storage.S3, obj *storage.Object) error {
if obj.Err != nil {
printError(c.fullCommand, c.op, obj.Err)
return obj.Err
}
if obj.Type.IsDir() {
return nil
}
func (c Cat) processSingleObject(ctx context.Context, client *storage.S3, url *url.URL) error {
buf := orderedwriter.New(os.Stdout)

_, err := client.Get(ctx, obj.URL, buf, c.concurrency, c.partSize)
if err != nil {
printError(c.fullCommand, c.op, err)
return err
}

return nil
_, err := client.Get(ctx, url, buf, c.concurrency, c.partSize)
return err
}

func validateCatCommand(c *cli.Context) error {
Expand Down

0 comments on commit fd902a9

Please sign in to comment.