Skip to content

Commit

Permalink
Ensure the source media files are not directly copied over to destina…
Browse files Browse the repository at this point in the history
…tion if it is handled by packager

Description:

  The TranformFactory might contain more transforms,  PackagerTransform and UploadTransform.

  But usually only one transform is needed for a specific source asset.

  When the source asset contains .ism, it is supposed to be handled by the PackagerTransform.
  When the source asset doesn't have .ism, it is UploadTransform's job to copy over media files.

  Each Transform instance has its own logic to determine what type of source asset can be supported by this transform.

  If a previous transform doesn't support such input asset, it returns status as Skipped,
  The next transform is invoked only when previous transform reports Skipped.

  Make sure the outputPath reported by all these transforms follow the same spec, which points to the destination folder only.
  • Loading branch information
weibz committed Jul 11, 2023
1 parent a457e69 commit 7693f36
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ams/AssetMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public async Task<MigrationResult> MigrateAsync(
result.Status = transformResult.Status;
result.OutputPath = transformResult.OutputPath;

if (result.Status == MigrationStatus.Failed)
if (result.Status != MigrationStatus.Skipped)
{
break;
}
Expand Down
2 changes: 1 addition & 1 deletion ams/StorageMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private async Task<MigrationResult> MigrateAsync(
result.Status = transformResult.Status;
result.OutputPath = transformResult.OutputPath;

if (result.Status == MigrationStatus.Failed)
if (result.Status != MigrationStatus.Skipped)
{
break;
}
Expand Down
5 changes: 4 additions & 1 deletion transform/PackageTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ await Task.WhenAll(
Directory.Delete(workingDirectory, true);
}

return $"{outputPath.Prefix}{Path.GetFileNameWithoutExtension(manifest.FileName)}";
// Mark the output container appropriately so that it won't be used as an input asset in new run.
await UpdateOutputStatus(outputPath.Container, cancellationToken);

return outputPath.Prefix;
}

private UploadPipe CreateUpload(string filePath, UploadHelper helper)
Expand Down
16 changes: 10 additions & 6 deletions transform/StorageTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ public async Task<AssetMigrationResult> RunAsync(
var result = new AssetMigrationResult();

_logger.LogTrace("Asset {asset} is in format: {format}.", details.AssetName, details.Manifest?.Format);
if (details.Manifest != null && details.Manifest.IsLive)
{
_logger.LogWarning("Skipping asset {asset} which is from a running live event. Rerun the migration after the live event is stopped.", details.AssetName);
result.Status = MigrationStatus.Skipped;
return result;
}

if (IsSupported(details))
{
Expand All @@ -62,6 +56,16 @@ public async Task<AssetMigrationResult> RunAsync(
result.Status = MigrationStatus.Failed;
}
}
else
{
var format = details.Manifest != null ? details.Manifest.Format : "non_ism";
_logger.LogInformation("The asset {asset} with format {format} is not supported by transform {transform} in current version, try next transform...",
details.AssetName,
format,
this.GetType().Name);

result.Status = MigrationStatus.Skipped;
}

return result;
}
Expand Down

0 comments on commit 7693f36

Please sign in to comment.