Skip to content

Commit

Permalink
Get correct file path on copying files (#3190)
Browse files Browse the repository at this point in the history
always pass in null file properties when getting file properties for a copied file as it is a new file and we need the new path
  • Loading branch information
esmadau authored Nov 10, 2023
1 parent 1745d21 commit 77a4c79
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public async Task GivenValidInputWithExistingFile_WhenCallingUpdateBlobAsync_Sho
var firstBlock = new KeyValuePair<string, long>(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), stream.Length);

_fileStore.CopyFileAsync(fileIdentifier, newFileIdentifier, Partition.Default, DefaultFileProperties, cancellationToken).Returns(Task.CompletedTask);
_fileStore.GetFilePropertiesAsync(newFileIdentifier, Partition.Default, DefaultFileProperties, cancellationToken).Returns(DefaultFileProperties);
_fileStore.GetFilePropertiesAsync(newFileIdentifier, Partition.Default, null, cancellationToken).Returns(DefaultFileProperties);
_fileStore.GetFileAsync(fileIdentifier, Partition.Default, DefaultFileProperties, cancellationToken).Returns(streamAndStoredFile.Value);
_metadataStore.GetInstanceMetadataAsync(fileIdentifier, cancellationToken).Returns(streamAndStoredFile.Key.Dataset);
_metadataStore.StoreInstanceMetadataAsync(streamAndStoredFile.Key.Dataset, newFileIdentifier, cancellationToken).Returns(Task.CompletedTask);
Expand All @@ -302,6 +302,7 @@ public async Task GivenValidInputWithExistingFile_WhenCallingUpdateBlobAsync_Sho
streamAndStoredFile.Key.Dataset.Remove(DicomTag.PixelData);

await _fileStore.Received(1).CopyFileAsync(fileIdentifier, newFileIdentifier, Partition.Default, DefaultFileProperties, cancellationToken);
await _fileStore.Received(1).GetFilePropertiesAsync(newFileIdentifier, Partition.Default, null, cancellationToken);
await _fileStore.DidNotReceive().GetFileAsync(fileIdentifier, Partition.Default, DefaultFileProperties, cancellationToken);
await _metadataStore.Received(1).GetInstanceMetadataAsync(fileIdentifier, cancellationToken);
await _metadataStore.Received(1).StoreInstanceMetadataAsync(streamAndStoredFile.Key.Dataset, newFileIdentifier, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private async Task<FileProperties> UpdateInstanceFileAsync(InstanceMetadata inst
{
_logger.LogInformation("Begin copying instance file {OrignalFileIdentifier} - {NewFileIdentifier}", originFileIdentifier, newFileIdentifier);
await _fileStore.CopyFileAsync(originFileIdentifier, newFileIdentifier, partition, instance.InstanceProperties.FileProperties, cancellationToken);
newFileProperties = await _fileStore.GetFilePropertiesAsync(newFileIdentifier, partition, instance.InstanceProperties.FileProperties, cancellationToken);
newFileProperties = await _fileStore.GetFilePropertiesAsync(newFileIdentifier, partition, null, cancellationToken);
}
else
{
Expand Down

0 comments on commit 77a4c79

Please sign in to comment.