@@ -146,64 +146,35 @@ public override async Task SetVfsMetadataAsync(
146146 string blobName ,
147147 CancellationToken cancellationToken = default )
148148 {
149- _logger . LogDebug ( "Getting VFS metadata for: {BlobName}" , blobName ) ;
150-
151- try
152- {
153- var blobMetadata = await _storage . GetBlobMetadataAsync ( blobName , cancellationToken ) ;
154- if ( blobMetadata . IsFailed || blobMetadata . Value . Metadata == null )
155- {
156- return null ;
157- }
158-
159- return ParseVfsMetadata ( blobMetadata . Value . Metadata ) ;
160- }
161- catch ( Exception ex )
162- {
163- _logger . LogError ( ex , "Error getting VFS metadata for: {BlobName}" , blobName ) ;
164- return null ;
165- }
149+ var metadata = await GetBlobInfoAsync ( blobName , cancellationToken ) ;
150+ return metadata ? . Metadata is { } values ? ParseVfsMetadata ( values ) : null ;
166151 }
167152
168153 public override async Task < IReadOnlyDictionary < string , string > > GetCustomMetadataAsync (
169154 string blobName ,
170155 CancellationToken cancellationToken = default )
171156 {
172- _logger . LogDebug ( "Getting custom metadata for: {BlobName}" , blobName ) ;
173-
174- try
175- {
176- var blobMetadata = await _storage . GetBlobMetadataAsync ( blobName , cancellationToken ) ;
177- if ( blobMetadata . IsFailed || blobMetadata . Value . Metadata == null )
178- {
179- return new Dictionary < string , string > ( ) ;
180- }
181-
182- return ExtractCustomMetadata ( blobMetadata . Value . Metadata ) ;
183- }
184- catch ( Exception ex )
185- {
186- _logger . LogError ( ex , "Error getting custom metadata for: {BlobName}" , blobName ) ;
187- return new Dictionary < string , string > ( ) ;
188- }
157+ var metadata = await GetBlobInfoAsync ( blobName , cancellationToken ) ;
158+ return metadata ? . Metadata is { } values
159+ ? ExtractCustomMetadata ( values )
160+ : new Dictionary < string , string > ( ) ;
189161 }
190162
191163 public override async Task < BlobMetadata ? > GetBlobInfoAsync (
192164 string blobName ,
193165 CancellationToken cancellationToken = default )
194166 {
195- _logger . LogDebug ( "Getting blob info for: {BlobName}" , blobName ) ;
196-
197- try
198- {
199- var result = await _storage . GetBlobMetadataAsync ( blobName , cancellationToken ) ;
200- return result . IsSuccess ? result . Value : null ;
201- }
202- catch ( Exception ex )
167+ cancellationToken . ThrowIfCancellationRequested ( ) ;
168+ var result = await _storage . GetBlobMetadataAsync ( blobName , cancellationToken ) ;
169+ // Portable providers may return cancellation as a failed Result. It must
170+ // neither become a missing file nor populate the VFS metadata cache.
171+ cancellationToken . ThrowIfCancellationRequested ( ) ;
172+ if ( result . IsFailed && result . Problem . StatusCode == 404 )
203173 {
204- _logger . LogDebug ( ex , "Blob not found or error getting blob info: {BlobName}" , blobName ) ;
205174 return null ;
206175 }
176+ result . ThrowIfProblem ( ) ;
177+ return result . Value ;
207178 }
208179}
209180
0 commit comments