@@ -117,13 +117,15 @@ private readonly async Task UploadBlob(string name, string digest, Stream conten
117
117
Debug . Assert ( pushResponse . Headers . Location is not null ) ;
118
118
119
119
UriBuilder x ;
120
- if ( pushResponse . Headers . Location . IsAbsoluteUri )
120
+ if ( pushResponse . Headers . Location is { IsAbsoluteUri : true } )
121
121
{
122
122
x = new UriBuilder ( pushResponse . Headers . Location ) ;
123
123
}
124
124
else
125
125
{
126
- x = new UriBuilder ( BaseUri + pushResponse . Headers . Location . OriginalString ) ;
126
+ // if we don't trim the BaseUri and relative Uri of slashes, you can get invalid urls.
127
+ // Uri constructor does this on our behalf.
128
+ x = new UriBuilder ( new Uri ( BaseUri , pushResponse . Headers . Location . OriginalString ) ) ;
127
129
}
128
130
129
131
x . Query += $ "&digest={ Uri . EscapeDataString ( digest ) } ";
@@ -199,23 +201,25 @@ public async Task Push(Image x, string name, string? tag, string baseName, Actio
199
201
200
202
// Ensure the blob is available locally
201
203
await x . originatingRegistry . Value . DownloadBlob ( x . OriginatingName , descriptor ) ;
202
- logProgressMessage ( $ "Finished uploading layer { digest } to registry") ;
203
204
// Then push it to the destination registry
204
205
await Push ( Layer . FromDescriptor ( descriptor ) , name , logProgressMessage ) ;
206
+ logProgressMessage ( $ "Finished uploading layer { digest } to registry") ;
205
207
}
206
208
}
207
209
208
- logProgressMessage ( $ "Uploading config to registry") ;
209
210
using ( MemoryStream stringStream = new MemoryStream ( Encoding . UTF8 . GetBytes ( x . config . ToJsonString ( ) ) ) )
210
211
{
211
- await UploadBlob ( name , x . GetDigest ( x . config ) , stringStream ) ;
212
+ var configDigest = x . GetDigest ( x . config ) ;
213
+ logProgressMessage ( $ "Uploading config to registry at blob { configDigest } ") ;
214
+ await UploadBlob ( name , configDigest , stringStream ) ;
212
215
logProgressMessage ( $ "Uploaded config to registry") ;
213
216
}
214
217
215
- logProgressMessage ( $ "Uploading manifest to registry") ;
218
+ var manifestDigest = x . GetDigest ( x . manifest ) ;
219
+ logProgressMessage ( $ "Uploading manifest to registry at blob { manifestDigest } ") ;
216
220
HttpContent manifestUploadContent = new StringContent ( x . manifest . ToJsonString ( ) ) ;
217
221
manifestUploadContent . Headers . ContentType = new MediaTypeHeaderValue ( DockerManifestV2 ) ;
218
- var putResponse = await client . PutAsync ( new Uri ( BaseUri , $ "/v2/{ name } /manifests/{ x . GetDigest ( x . manifest ) } ") , manifestUploadContent ) ;
222
+ var putResponse = await client . PutAsync ( new Uri ( BaseUri , $ "/v2/{ name } /manifests/{ manifestDigest } ") , manifestUploadContent ) ;
219
223
string putresponsestr = await putResponse . Content . ReadAsStringAsync ( ) ;
220
224
221
225
if ( ! putResponse . IsSuccessStatusCode )
@@ -226,7 +230,7 @@ public async Task Push(Image x, string name, string? tag, string baseName, Actio
226
230
227
231
logProgressMessage ( $ "Uploaded manifest to registry") ;
228
232
229
- logProgressMessage ( $ "Uploading tag to registry") ;
233
+ logProgressMessage ( $ "Uploading tag { tag } to registry") ;
230
234
var putResponse2 = await client . PutAsync ( new Uri ( BaseUri , $ "/v2/{ name } /manifests/{ tag } ") , manifestUploadContent ) ;
231
235
232
236
if ( ! putResponse2 . IsSuccessStatusCode )
0 commit comments