20
20
import java .io .ByteArrayInputStream ;
21
21
import java .io .File ;
22
22
import java .io .IOException ;
23
+ import java .net .MalformedURLException ;
24
+ import java .net .URL ;
23
25
import java .text .ParseException ;
24
26
import java .util .ArrayList ;
25
27
import java .util .Arrays ;
@@ -249,9 +251,9 @@ protected void putChecksum(Artifact artifact, File src, String dest, boolean ove
249
251
try {
250
252
FileUtil .copy (new ByteArrayInputStream (ChecksumHelper .computeAsString (src , algorithm )
251
253
.getBytes ()), csFile , null );
252
- repository .put (
253
- DefaultArtifact . cloneWithAnotherTypeAndExt ( artifact , algorithm , artifact .getExt ()
254
- + "." + algorithm ), csFile , dest + "." + algorithm , overwrite );
254
+ repository .put (DefaultArtifact . cloneWithAnotherTypeAndExt ( artifact , algorithm ,
255
+ artifact .getExt () + "." + algorithm ), csFile ,
256
+ chopQuery ( dest , algorithm ) , overwrite );
255
257
} finally {
256
258
csFile .delete ();
257
259
}
@@ -269,15 +271,30 @@ protected void putSignature(Artifact artifact, File src, String dest, boolean ov
269
271
270
272
try {
271
273
gen .sign (src , tempFile );
272
- repository .put (
273
- DefaultArtifact .cloneWithAnotherTypeAndExt (artifact , gen .getExtension (),
274
+ repository .put (DefaultArtifact .cloneWithAnotherTypeAndExt (artifact , gen .getExtension (),
274
275
artifact .getExt () + "." + gen .getExtension ()), tempFile ,
275
- dest + "." + gen .getExtension (), overwrite );
276
+ chopQuery ( dest , gen .getExtension () ), overwrite );
276
277
} finally {
277
278
tempFile .delete ();
278
279
}
279
280
}
280
281
282
+ private String chopQuery (String dest , String algorithm ) {
283
+ if (!dest .contains ("?" )) {
284
+ return dest + "." + algorithm ;
285
+ }
286
+ try {
287
+ URL url = new URL (dest );
288
+ String query = url .getQuery ();
289
+ if (query == null ) {
290
+ query = "" ;
291
+ }
292
+ return dest .replace ("?" + query , "" ) + "." + algorithm ;
293
+ } catch (MalformedURLException e ) {
294
+ throw new IllegalArgumentException (e );
295
+ }
296
+ }
297
+
281
298
@ Override
282
299
public DownloadReport download (Artifact [] artifacts , DownloadOptions options ) {
283
300
EventManager eventManager = getEventManager ();
0 commit comments