Skip to content

Commit

Permalink
task: Fix usages of api.AssetSpec.Storage field, now a ptr (#238)
Browse files Browse the repository at this point in the history
Sometimes I hate go verbosity
  • Loading branch information
victorges authored May 23, 2024
1 parent 3d2a29a commit e15ba37
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
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{}
}
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
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
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 {
// 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 e15ba37

Please sign in to comment.