@@ -323,10 +323,13 @@ func (n *Nexus3) checkLocalChecksumAndCompareWithOneInRemote(f, localDiskRepo, d
323
323
scheme = "https"
324
324
}
325
325
326
- u := scheme + "://" + n .FQDN + "/repository/" + localDiskRepo + "/" + dir + "/" + filename + ".sha512"
327
- log .Debugf ("upload URL: '%s'" , u )
326
+ // URL for checking the sha512 checksum of a file that has been stored in Nexus3
327
+ // which has to be compared with the one of the downloaded file.
328
+ // If equal then do not upload the file again
329
+ checksumOfArtifactInNexus3Sha512URL := scheme + "://" + n .FQDN + "/repository/" + localDiskRepo + "/" + dir + "/" + filename + ".sha512"
330
+ log .Debugf ("checksumOfArtifactInNexus3Sha512URL: '%s'" , checksumOfArtifactInNexus3Sha512URL )
328
331
329
- req , err := http .NewRequest ("GET" , u , nil )
332
+ req , err := http .NewRequest ("GET" , checksumOfArtifactInNexus3Sha512URL , nil )
330
333
if err != nil {
331
334
return false , err
332
335
}
@@ -341,20 +344,16 @@ func (n *Nexus3) checkLocalChecksumAndCompareWithOneInRemote(f, localDiskRepo, d
341
344
panic (err )
342
345
}
343
346
}()
344
- defer func () {
345
- if err := resp .Body .Close (); err != nil {
346
- panic (err )
347
- }
348
- }()
349
347
bodyBytes , err := io .ReadAll (resp .Body )
350
348
if err != nil {
351
349
return false , err
352
350
}
353
- bodyString := string (bodyBytes )
354
- log .Debugf ("checksum of artifact in nexus3: '%s'" , bodyString )
351
+ checksumOfArtifactInNexus3 := string (bodyBytes )
352
+ log .Debugf ("checksum of artifact in nexus3: '%s'" , checksumOfArtifactInNexus3 )
355
353
356
- if bodyString == downloadedFileChecksum {
354
+ if checksumOfArtifactInNexus3 == downloadedFileChecksum {
357
355
identical = true
356
+ log .Infof ("the checksum of the filesystem: '%s' is identical to the one in Nexus3: '%s'. Outcome: '%t'" , downloadedFileChecksum , checksumOfArtifactInNexus3 , identical )
358
357
}
359
358
360
359
return identical , nil
@@ -466,29 +465,28 @@ func (n *Nexus3) UploadSingleArtifact(client *client.Nexus3, path, localDiskRepo
466
465
c .Maven2Version = & mp .version
467
466
468
467
// Match "/some/group/" and capture the group name.
469
- regex := `^` + localDiskRepoHome + `/([\w+\/]+)/` + mp .artifact
468
+ regex := `^` + localDiskRepoHome + `/([\.\-\d+\ w+\/]+)/` + mp .artifact
470
469
re := regexp .MustCompile (regex )
471
470
groupID := ""
472
471
473
472
// Extract the group name from the path.
473
+ // * the path will be validated
474
+ // * subsequently the groupID will be extracted from the path. Note: a groupID could be: 'some/group/some/artifact'
474
475
match := re .FindStringSubmatch (path )
475
476
if len (match ) >= 2 {
477
+ log .Tracef ("elements: '%v' that were found that are required to determine the groupID" , match )
476
478
groupID = match [1 ]
479
+ log .Debugf ("the following groupID has been found: '%s'" , groupID )
477
480
groupID = strings .ReplaceAll (groupID , `/` , `.` )
481
+ log .Tracef ("groupID without slash: '%s'" , groupID )
478
482
} else {
479
483
return false , fmt .Errorf ("groupID should not be empty, path: '%s' and regex: '%s'" , path , regex )
480
484
}
481
485
c .Maven2GroupID = & groupID
482
486
generatePOM := true
483
487
c .Maven2GeneratePom = & generatePOM
484
488
485
- maven2Asset1 := "empty"
486
- maven2Asset2 := "empty"
487
- maven2Asset3 := "empty"
488
- maven2Asset4 := "empty"
489
- maven2Asset5 := "empty"
490
- maven2Asset6 := "empty"
491
- maven2Asset7 := "empty"
489
+ maven2Asset1 , maven2Asset2 , maven2Asset3 , maven2Asset4 , maven2Asset5 , maven2Asset6 , maven2Asset7 := "empty" , "empty" , "empty" , "empty" , "empty" , "empty" , "empty"
492
490
493
491
if c .Maven2Asset1 != nil {
494
492
maven2Asset1 = c .Maven2Asset1 .Name ()
0 commit comments