From 3b50b7ec05b130aacff04cc96c4bc9fc32b18d9d Mon Sep 17 00:00:00 2001 From: "John K. Luebs" Date: Wed, 4 Oct 2023 11:55:03 -0500 Subject: [PATCH] Rename hardlink to hard link (two words) --- go.mod | 2 +- src/duplicacy_backupmanager.go | 34 +++++++++++++++++----------------- src/duplicacy_entry.go | 10 +++++----- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index b30772a..4e705a0 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( golang.org/x/crypto v0.12.0 golang.org/x/net v0.10.0 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d + golang.org/x/sys v0.11.0 google.golang.org/api v0.21.0 storj.io/uplink v1.12.0 ) @@ -63,7 +64,6 @@ require ( go.opencensus.io v0.22.3 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect golang.org/x/tools v0.9.1 // indirect diff --git a/src/duplicacy_backupmanager.go b/src/duplicacy_backupmanager.go index 0f19459..14536da 100644 --- a/src/duplicacy_backupmanager.go +++ b/src/duplicacy_backupmanager.go @@ -710,11 +710,11 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu var hardLinkTable []hardLinkEntry var hardLinks []*Entry - restoreHardlink := func(entry *Entry, fullPath string) bool { - if entry.IsHardlinkRoot() { + restoreHardLink := func(entry *Entry, fullPath string) bool { + if entry.IsHardLinkRoot() { hardLinkTable[len(hardLinkTable)-1].willExist = true - } else if entry.IsHardlinkedFrom() { - i, err := entry.GetHardlinkId() + } else if entry.IsHardLinkChild() { + i, err := entry.GetHardLinkId() if err != nil { LOG_ERROR("RESTORE_HARDLINK", "Decode error for hard link entry %s: %v", entry.Path, err) return false @@ -735,7 +735,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu for remoteEntry := range remoteListingChannel { - if remoteEntry.IsHardlinkRoot() { + if remoteEntry.IsHardLinkRoot() { hardLinkTable = append(hardLinkTable, hardLinkEntry{remoteEntry, false}) } @@ -782,7 +782,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu isRegular, link, err := Readlink(fullPath) if err == nil && link == remoteEntry.Link && !isRegular { remoteEntry.RestoreMetadata(fullPath, nil, setOwner) - if remoteEntry.IsHardlinkRoot() { + if remoteEntry.IsHardLinkRoot() { hardLinkTable[len(hardLinkTable)-1].willExist = true } continue @@ -798,7 +798,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu os.Remove(fullPath) } - if restoreHardlink(remoteEntry, fullPath) { + if restoreHardLink(remoteEntry, fullPath) { continue } @@ -833,7 +833,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu if stat, _ := os.Lstat(fullPath); stat != nil { if remoteEntry.IsSameSpecial(stat) { remoteEntry.RestoreMetadata(fullPath, nil, setOwner) - if remoteEntry.IsHardlinkRoot() { + if remoteEntry.IsHardLinkRoot() { hardLinkTable[len(hardLinkTable)-1].willExist = true } } @@ -845,7 +845,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu os.Remove(fullPath) } - if restoreHardlink(remoteEntry, fullPath) { + if restoreHardLink(remoteEntry, fullPath) { continue } @@ -857,10 +857,10 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu LOG_TRACE("DOWNLOAD_DONE", "Special %s %s restored", remoteEntry.Path, remoteEntry.FmtSpecial()) } else { - if remoteEntry.IsHardlinkRoot() { + if remoteEntry.IsHardLinkRoot() { hardLinkTable[len(hardLinkTable)-1].willExist = true - } else if remoteEntry.IsHardlinkedFrom() { - i, err := remoteEntry.GetHardlinkId() + } else if remoteEntry.IsHardLinkChild() { + i, err := remoteEntry.GetHardLinkId() if err != nil { LOG_ERROR("RESTORE_HARDLINK", "Decode error for hard link entry %s: %v", remoteEntry.Path, err) return 0 @@ -994,7 +994,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu for _, linkEntry := range hardLinks { - i, _ := linkEntry.GetHardlinkId() + i, _ := linkEntry.GetHardLinkId() sourcePath := joinPath(top, hardLinkTable[i].entry.Path) fullPath := joinPath(top, linkEntry.Path) @@ -1199,7 +1199,7 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s entry.StartChunk -= delta entry.EndChunk -= delta - if entry.IsHardlinkRoot() { + if entry.IsHardLinkRoot() { hardLinkTable = append(hardLinkTable, hardLinkEntry{entry, entry.StartChunk}) } @@ -1207,8 +1207,8 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s entry.StartChunk -= lastEndChunk lastEndChunk = entry.EndChunk entry.EndChunk = delta - } else if entry.IsHardlinkedFrom() { - i, err := entry.GetHardlinkId() + } else if entry.IsHardLinkChild() { + i, err := entry.GetHardLinkId() if err != nil { LOG_ERROR("SNAPSHOT_UPLOAD", "Decode error for hard link entry %s: %v", entry.Link, err) return err @@ -1224,7 +1224,7 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s } entry = entry.HardLinkTo(targetEntry, startChunk, endChunk) - } else if entry.IsHardlinkRoot() { + } else if entry.IsHardLinkRoot() { hardLinkTable = append(hardLinkTable, hardLinkEntry{entry, 0}) } diff --git a/src/duplicacy_entry.go b/src/duplicacy_entry.go index 0053329..1d1d58f 100644 --- a/src/duplicacy_entry.go +++ b/src/duplicacy_entry.go @@ -530,21 +530,21 @@ func (entry *Entry) IsComplete() bool { return entry.Size >= 0 } -func (entry *Entry) IsHardlinkedFrom() bool { +func (entry *Entry) IsHardLinkChild() bool { return (entry.IsFile() && len(entry.Link) > 0 && entry.Link != "/") || (!entry.IsDir() && entry.EndChunk == entryHardLinkTargetChunkMarker) } -func (entry *Entry) IsHardlinkRoot() bool { +func (entry *Entry) IsHardLinkRoot() bool { return (entry.IsFile() && entry.Link == "/") || (!entry.IsDir() && entry.EndChunk == entryHardLinkRootChunkMarker) } -func (entry *Entry) GetHardlinkId() (int, error) { +func (entry *Entry) GetHardLinkId() (int, error) { if entry.IsFile() { i, err := strconv.ParseUint(entry.Link, 16, 64) return int(i), err } else { if entry.EndChunk != entryHardLinkTargetChunkMarker { - return 0, errors.New("Symlink entry not marked as hardlinked") + return 0, errors.New("Entry not marked as hard link child") } return entry.EndOffset, nil } @@ -823,7 +823,7 @@ func ListEntries(top string, path string, patterns []string, nobackupFile string k := listEntryLinkKey{dev: uint64(stat.Dev), ino: uint64(stat.Ino)} if linkIndex, seen := listingState.linkTable[k]; seen { if linkIndex == -1 { - LOG_DEBUG("LIST_EXCLUDE", "%s is excluded by attribute (hardlink)", entry.Path) + LOG_DEBUG("LIST_EXCLUDE", "%s is excluded by attribute (hard link)", entry.Path) continue } entry.Size = 0