Skip to content

Commit

Permalink
chore: use atomic.Uint64
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijie-yang committed Nov 28, 2024
1 parent 3a9a338 commit c7322fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/manifest/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Report struct {

// curHardLinkId is used internally to allocate unique HardLinkId for hard
// links.
curHardLinkId uint64
curHardLinkId atomic.Uint64
}

const NON_HARD_LINK uint64 = 0
Expand Down Expand Up @@ -98,8 +98,8 @@ func (r *Report) getHardLinkId(fsEntry *fsutil.Entry) uint64 {
relLinkPath, _ := r.sanitizeAbsPath(fsEntry.Link, false)
if entry, ok := r.Entries[relLinkPath]; ok {
if entry.HardLinkId == NON_HARD_LINK {
atomic.AddUint64(&r.curHardLinkId, 1)
entry.HardLinkId = r.curHardLinkId
entry.HardLinkId = r.curHardLinkId.Add(1)
r.curHardLinkId.Store(entry.HardLinkId)
r.Entries[relLinkPath] = entry
}
hardLinkId = entry.HardLinkId
Expand Down

0 comments on commit c7322fa

Please sign in to comment.