Skip to content

Commit 40355f4

Browse files
authored
fix: [#495] Upload issues due to incomplete regex. (#498)
1 parent 562bc49 commit 40355f4

File tree

5 files changed

+35
-26
lines changed

5 files changed

+35
-26
lines changed

Taskfile.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: '3'
44
env:
55
GIT_CHGLOG_URL: https://github.com/git-chglog/git-chglog/releases/download
66
GIT_CHGLOG_VERSION: v0.15.1/git-chglog_0.15.1_linux_amd64.tar.gz
7-
CHANGELOG_NEXT_TAG: 7.5.0
7+
CHANGELOG_NEXT_TAG: 7.5.1
88

99
tasks:
1010
changelog:

build/package/snap/snapcraft.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: n3dr
33
base: core22
4-
version: 7.5.0
4+
version: 7.5.1
55
summary: Nexus3 Disaster Recovery
66
description: |
77
Download all artifacts at once or migrate automatically from Nexus to Nexus.

docs/CHANGELOG.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
## [Unreleased]
33

44

5+
<a name="7.5.1"></a>
6+
## [7.5.1] - 2024-02-24
7+
### Build
8+
- **deps:** bump schubergphilis/mcvs-golang-action from 0.3.0 to 0.4.1 ([#483](https://github.com/030/n3dr/issues/483))
9+
10+
### Fix
11+
- [[#495](https://github.com/030/n3dr/issues/495)] Upload issues due to incomplete regex.
12+
- [[#493](https://github.com/030/n3dr/issues/493)] Resolve issue in integration test. ([#494](https://github.com/030/n3dr/issues/494))
13+
14+
515
<a name="7.5.0"></a>
616
## [7.5.0] - 2024-02-10
717
### Build
@@ -13,7 +23,7 @@
1323
- **deps:** bump github.com/docker/docker from 20.10.24+incompatible to 20.10.27+incompatible ([#466](https://github.com/030/n3dr/issues/466))
1424

1525
### Feat
16-
- [[#459](https://github.com/030/n3dr/issues/459)] Display how long N3DR was running.
26+
- [[#459](https://github.com/030/n3dr/issues/459)] Display how long N3DR was running. ([#475](https://github.com/030/n3dr/issues/475))
1727

1828

1929
<a name="7.4.1"></a>
@@ -474,7 +484,8 @@ The `backup`, `upload` and `repositories` commands have been removed.
474484
<a name="1.0.0"></a>
475485
## 1.0.0 - 2019-05-12
476486

477-
[Unreleased]: https://github.com/030/n3dr/compare/7.5.0...HEAD
487+
[Unreleased]: https://github.com/030/n3dr/compare/7.5.1...HEAD
488+
[7.5.1]: https://github.com/030/n3dr/compare/7.5.0...7.5.1
478489
[7.5.0]: https://github.com/030/n3dr/compare/7.4.1...7.5.0
479490
[7.4.1]: https://github.com/030/n3dr/compare/7.4.0...7.4.1
480491
[7.4.0]: https://github.com/030/n3dr/compare/7.3.3...7.4.0

docs/quickstarts/snippets/n3dr/DOWNLOAD.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Download
22

3-
Download the [latest N3DR binary](https://github.com/030/n3dr/releases/tag/7.5.0):
3+
Download the [latest N3DR binary](https://github.com/030/n3dr/releases/tag/7.5.1):
44

55
```bash
66
cd /tmp && \
7-
curl -L https://github.com/030/n3dr/releases/download/7.5.0/n3dr-ubuntu-latest \
7+
curl -L https://github.com/030/n3dr/releases/download/7.5.1/n3dr-ubuntu-latest \
88
-o n3dr-ubuntu-latest && \
9-
curl -L https://github.com/030/n3dr/releases/download/7.5.0/\
9+
curl -L https://github.com/030/n3dr/releases/download/7.5.1/\
1010
n3dr-ubuntu-latest.sha512.txt \
1111
-o n3dr-ubuntu-latest.sha512.txt && \
1212
sha512sum -c n3dr-ubuntu-latest.sha512.txt && \

internal/app/n3dr/artifactsv2/upload/upload.go

+17-19
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,13 @@ func (n *Nexus3) checkLocalChecksumAndCompareWithOneInRemote(f, localDiskRepo, d
323323
scheme = "https"
324324
}
325325

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)
328331

329-
req, err := http.NewRequest("GET", u, nil)
332+
req, err := http.NewRequest("GET", checksumOfArtifactInNexus3Sha512URL, nil)
330333
if err != nil {
331334
return false, err
332335
}
@@ -341,20 +344,16 @@ func (n *Nexus3) checkLocalChecksumAndCompareWithOneInRemote(f, localDiskRepo, d
341344
panic(err)
342345
}
343346
}()
344-
defer func() {
345-
if err := resp.Body.Close(); err != nil {
346-
panic(err)
347-
}
348-
}()
349347
bodyBytes, err := io.ReadAll(resp.Body)
350348
if err != nil {
351349
return false, err
352350
}
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)
355353

356-
if bodyString == downloadedFileChecksum {
354+
if checksumOfArtifactInNexus3 == downloadedFileChecksum {
357355
identical = true
356+
log.Infof("the checksum of the filesystem: '%s' is identical to the one in Nexus3: '%s'. Outcome: '%t'", downloadedFileChecksum, checksumOfArtifactInNexus3, identical)
358357
}
359358

360359
return identical, nil
@@ -466,29 +465,28 @@ func (n *Nexus3) UploadSingleArtifact(client *client.Nexus3, path, localDiskRepo
466465
c.Maven2Version = &mp.version
467466

468467
// Match "/some/group/" and capture the group name.
469-
regex := `^` + localDiskRepoHome + `/([\w+\/]+)/` + mp.artifact
468+
regex := `^` + localDiskRepoHome + `/([\.\-\d+\w+\/]+)/` + mp.artifact
470469
re := regexp.MustCompile(regex)
471470
groupID := ""
472471

473472
// 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'
474475
match := re.FindStringSubmatch(path)
475476
if len(match) >= 2 {
477+
log.Tracef("elements: '%v' that were found that are required to determine the groupID", match)
476478
groupID = match[1]
479+
log.Debugf("the following groupID has been found: '%s'", groupID)
477480
groupID = strings.ReplaceAll(groupID, `/`, `.`)
481+
log.Tracef("groupID without slash: '%s'", groupID)
478482
} else {
479483
return false, fmt.Errorf("groupID should not be empty, path: '%s' and regex: '%s'", path, regex)
480484
}
481485
c.Maven2GroupID = &groupID
482486
generatePOM := true
483487
c.Maven2GeneratePom = &generatePOM
484488

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"
492490

493491
if c.Maven2Asset1 != nil {
494492
maven2Asset1 = c.Maven2Asset1.Name()

0 commit comments

Comments
 (0)