Skip to content

Commit

Permalink
task: Fix usages of api.AssetSpec.Storage field, now a ptr
Browse files Browse the repository at this point in the history
Sometimes I hate go verbosity
  • Loading branch information
victorges committed May 23, 2024
1 parent 3d2a29a commit 7cef519
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion task/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ func deleteAsset(asset *api.Asset, r *runner, ctx context.Context) error {

glog.Infof("Deleted %v files from asset=%v", totalDeleted, asset.ID)

if ipfs := asset.AssetSpec.Storage.IPFS; ipfs != nil {
if storage := asset.AssetSpec.Storage; storage != nil && storage.IPFS != nil {
ipfs := storage.IPFS

Check warning on line 665 in task/runner.go

View check run for this annotation

Codecov / codecov/patch

task/runner.go#L664-L665

Added lines #L664 - L665 were not covered by tests
err = r.UnpinFromIpfs(ctx, ipfs.CID, "cid")
if err != nil {
glog.Errorf("Error unpinning from IPFS %v", ipfs.CID)
Expand Down
13 changes: 9 additions & 4 deletions task/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ func processCatalystCallback(tctx *TaskContext, callback *clients.CatalystCallba
})
}
case OutputNameIPFSSourceMP4:
if assetSpec.Storage == nil {
assetSpec.Storage = &api.AssetStorage{IPFS: &api.AssetIPFS{}}
} else if assetSpec.Storage.IPFS == nil {
assetSpec.Storage.IPFS = &api.AssetIPFS{}

Check warning on line 481 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L478-L481

Added lines #L478 - L481 were not covered by tests
}
assetSpec.Storage.IPFS.CID = output.Manifest
default:
return nil, fmt.Errorf("unknown output name=%q for output=%+v", outName, output)
Expand Down Expand Up @@ -552,8 +557,8 @@ func complementCatalystPipeline(tctx *TaskContext, assetSpec api.AssetSpec) (*da
}
defer contents.Close()

ipfsSpec := tctx.OutputAsset.Storage.IPFS
ipfsRequired := ipfsSpec != nil && ipfsSpec.Spec != nil
storage := tctx.OutputAsset.Storage
ipfsRequired := storage != nil && storage.IPFS != nil && storage.IPFS.Spec != nil

Check warning on line 561 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L560-L561

Added lines #L560 - L561 were not covered by tests
if !ipfsRequired && catalystCopiedSource {
glog.Infof("Skipping file download")
return &data.UploadTaskOutput{AssetSpec: assetSpec}, nil
Expand Down Expand Up @@ -591,7 +596,7 @@ func complementCatalystPipeline(tctx *TaskContext, assetSpec api.AssetSpec) (*da
}

if ipfsRequired {
ipfs := *ipfsSpec
ipfs := *storage.IPFS

Check warning on line 599 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L599

Added line #L599 was not covered by tests
if !FlagCatalystSupportsIPFS {
// TODO: Remove this branch once we have reliable catalyst IPFS support
var (
Expand Down Expand Up @@ -724,7 +729,7 @@ func uploadTaskOutputLocations(tctx *TaskContext) ([]OutputName, []clients.Outpu
return nil, nil, err
}
// Add Pinata output location
if FlagCatalystSupportsIPFS && tctx.OutputAsset.Storage.IPFS != nil {
if FlagCatalystSupportsIPFS && tctx.OutputAsset.Storage != nil && tctx.OutputAsset.Storage.IPFS != nil {

Check warning on line 732 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L732

Added line #L732 was not covered by tests
// TODO: This interface is likely going to change so that pinata is just a
// `object_store` output
outputNames, outputLocations =
Expand Down

0 comments on commit 7cef519

Please sign in to comment.