Skip to content

Commit

Permalink
asset migrate throws exception and quits if the container for the ass…
Browse files Browse the repository at this point in the history
…et doesn't exist. mark as failed instead
  • Loading branch information
pohhsu committed Jul 7, 2023
1 parent 091d8df commit 2b35511
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions ams/AssetMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,36 @@ public async Task<MigrationResult> MigrateAsync(
MediaAssetResource asset,
CancellationToken cancellationToken)
{
AssetMigrationResult result = new AssetMigrationResult(MigrationStatus.NotMigrated);
_logger.LogInformation("Migrating asset: {name} (container {container}) ...", asset.Data.Name, asset.Data.Container);
var container = storage.GetContainer(asset);

// Get the inital migration status from the container level's metadata list.
var result = await _tracker.GetMigrationStatusAsync(container, cancellationToken);

if (_options.SkipMigrated)
try
{
if (result.Status == MigrationStatus.Completed)
{
_logger.LogDebug("Asset: {name} has already been migrated.", asset.Data.Name);
var container = storage.GetContainer(asset);

result.Status = MigrationStatus.AlreadyMigrated;
if (!await container.ExistsAsync(cancellationToken))
{
_logger.LogWarning("Container {name} missing for asset {asset}", container.Name, asset.Data.Name);
result.Status = MigrationStatus.Failed;
_logger.LogDebug("Migrated asset: {asset}, container: {container}, type: {type}, status: {status}", asset.Data.Name, asset.Data.Container, result.AssetType, result.Status);
return result;
}
}

try
{
// Get the initial migration status from the container level's metadata list.
result = await _tracker.GetMigrationStatusAsync(container, cancellationToken);

if (_options.SkipMigrated)
{
if (result.Status == MigrationStatus.Completed)
{
_logger.LogDebug("Asset: {name} has already been migrated.", asset.Data.Name);

result.Status = MigrationStatus.AlreadyMigrated;
_logger.LogDebug("Migrated asset: {asset}, container: {container}, type: {type}, status: {status}", asset.Data.Name, asset.Data.Container, result.AssetType, result.Status);
return result;
}
}

if (asset.Data.StorageEncryptionFormat != MediaAssetStorageEncryptionFormat.None)
{
_logger.LogWarning("Asset {name} is encrypted using {format}", asset.Data.Name, asset.Data.StorageEncryptionFormat);
Expand Down

0 comments on commit 2b35511

Please sign in to comment.