mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-02 11:44:45 -06:00
Rename hardlink to hard link (two words)
This commit is contained in:
2
go.mod
2
go.mod
@@ -27,6 +27,7 @@ require (
|
|||||||
golang.org/x/crypto v0.12.0
|
golang.org/x/crypto v0.12.0
|
||||||
golang.org/x/net v0.10.0
|
golang.org/x/net v0.10.0
|
||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||||
|
golang.org/x/sys v0.11.0
|
||||||
google.golang.org/api v0.21.0
|
google.golang.org/api v0.21.0
|
||||||
storj.io/uplink v1.12.1
|
storj.io/uplink v1.12.1
|
||||||
)
|
)
|
||||||
@@ -63,7 +64,6 @@ require (
|
|||||||
go.opencensus.io v0.22.3 // indirect
|
go.opencensus.io v0.22.3 // indirect
|
||||||
golang.org/x/mod v0.10.0 // indirect
|
golang.org/x/mod v0.10.0 // indirect
|
||||||
golang.org/x/sync v0.3.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/term v0.11.0 // indirect
|
||||||
golang.org/x/text v0.12.0 // indirect
|
golang.org/x/text v0.12.0 // indirect
|
||||||
golang.org/x/tools v0.9.1 // indirect
|
golang.org/x/tools v0.9.1 // indirect
|
||||||
|
|||||||
@@ -710,11 +710,11 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
|
|||||||
var hardLinkTable []hardLinkEntry
|
var hardLinkTable []hardLinkEntry
|
||||||
var hardLinks []*Entry
|
var hardLinks []*Entry
|
||||||
|
|
||||||
restoreHardlink := func(entry *Entry, fullPath string) bool {
|
restoreHardLink := func(entry *Entry, fullPath string) bool {
|
||||||
if entry.IsHardlinkRoot() {
|
if entry.IsHardLinkRoot() {
|
||||||
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
||||||
} else if entry.IsHardlinkedFrom() {
|
} else if entry.IsHardLinkChild() {
|
||||||
i, err := entry.GetHardlinkId()
|
i, err := entry.GetHardLinkId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LOG_ERROR("RESTORE_HARDLINK", "Decode error for hard link entry %s: %v", entry.Path, err)
|
LOG_ERROR("RESTORE_HARDLINK", "Decode error for hard link entry %s: %v", entry.Path, err)
|
||||||
return false
|
return false
|
||||||
@@ -735,7 +735,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
|
|||||||
|
|
||||||
for remoteEntry := range remoteListingChannel {
|
for remoteEntry := range remoteListingChannel {
|
||||||
|
|
||||||
if remoteEntry.IsHardlinkRoot() {
|
if remoteEntry.IsHardLinkRoot() {
|
||||||
hardLinkTable = append(hardLinkTable, hardLinkEntry{remoteEntry, false})
|
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)
|
isRegular, link, err := Readlink(fullPath)
|
||||||
if err == nil && link == remoteEntry.Link && !isRegular {
|
if err == nil && link == remoteEntry.Link && !isRegular {
|
||||||
remoteEntry.RestoreMetadata(fullPath, nil, setOwner)
|
remoteEntry.RestoreMetadata(fullPath, nil, setOwner)
|
||||||
if remoteEntry.IsHardlinkRoot() {
|
if remoteEntry.IsHardLinkRoot() {
|
||||||
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -798,7 +798,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
|
|||||||
os.Remove(fullPath)
|
os.Remove(fullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if restoreHardlink(remoteEntry, fullPath) {
|
if restoreHardLink(remoteEntry, fullPath) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,7 +833,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
|
|||||||
if stat, _ := os.Lstat(fullPath); stat != nil {
|
if stat, _ := os.Lstat(fullPath); stat != nil {
|
||||||
if remoteEntry.IsSameSpecial(stat) {
|
if remoteEntry.IsSameSpecial(stat) {
|
||||||
remoteEntry.RestoreMetadata(fullPath, nil, setOwner)
|
remoteEntry.RestoreMetadata(fullPath, nil, setOwner)
|
||||||
if remoteEntry.IsHardlinkRoot() {
|
if remoteEntry.IsHardLinkRoot() {
|
||||||
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -845,7 +845,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
|
|||||||
os.Remove(fullPath)
|
os.Remove(fullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if restoreHardlink(remoteEntry, fullPath) {
|
if restoreHardLink(remoteEntry, fullPath) {
|
||||||
continue
|
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())
|
LOG_TRACE("DOWNLOAD_DONE", "Special %s %s restored", remoteEntry.Path, remoteEntry.FmtSpecial())
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if remoteEntry.IsHardlinkRoot() {
|
if remoteEntry.IsHardLinkRoot() {
|
||||||
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
hardLinkTable[len(hardLinkTable)-1].willExist = true
|
||||||
} else if remoteEntry.IsHardlinkedFrom() {
|
} else if remoteEntry.IsHardLinkChild() {
|
||||||
i, err := remoteEntry.GetHardlinkId()
|
i, err := remoteEntry.GetHardLinkId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LOG_ERROR("RESTORE_HARDLINK", "Decode error for hard link entry %s: %v", remoteEntry.Path, err)
|
LOG_ERROR("RESTORE_HARDLINK", "Decode error for hard link entry %s: %v", remoteEntry.Path, err)
|
||||||
return 0
|
return 0
|
||||||
@@ -994,7 +994,7 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
|
|||||||
|
|
||||||
for _, linkEntry := range hardLinks {
|
for _, linkEntry := range hardLinks {
|
||||||
|
|
||||||
i, _ := linkEntry.GetHardlinkId()
|
i, _ := linkEntry.GetHardLinkId()
|
||||||
sourcePath := joinPath(top, hardLinkTable[i].entry.Path)
|
sourcePath := joinPath(top, hardLinkTable[i].entry.Path)
|
||||||
fullPath := joinPath(top, linkEntry.Path)
|
fullPath := joinPath(top, linkEntry.Path)
|
||||||
|
|
||||||
@@ -1199,7 +1199,7 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s
|
|||||||
entry.StartChunk -= delta
|
entry.StartChunk -= delta
|
||||||
entry.EndChunk -= delta
|
entry.EndChunk -= delta
|
||||||
|
|
||||||
if entry.IsHardlinkRoot() {
|
if entry.IsHardLinkRoot() {
|
||||||
hardLinkTable = append(hardLinkTable, hardLinkEntry{entry, entry.StartChunk})
|
hardLinkTable = append(hardLinkTable, hardLinkEntry{entry, entry.StartChunk})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,8 +1207,8 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s
|
|||||||
entry.StartChunk -= lastEndChunk
|
entry.StartChunk -= lastEndChunk
|
||||||
lastEndChunk = entry.EndChunk
|
lastEndChunk = entry.EndChunk
|
||||||
entry.EndChunk = delta
|
entry.EndChunk = delta
|
||||||
} else if entry.IsHardlinkedFrom() {
|
} else if entry.IsHardLinkChild() {
|
||||||
i, err := entry.GetHardlinkId()
|
i, err := entry.GetHardLinkId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LOG_ERROR("SNAPSHOT_UPLOAD", "Decode error for hard link entry %s: %v", entry.Link, err)
|
LOG_ERROR("SNAPSHOT_UPLOAD", "Decode error for hard link entry %s: %v", entry.Link, err)
|
||||||
return err
|
return err
|
||||||
@@ -1224,7 +1224,7 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s
|
|||||||
}
|
}
|
||||||
entry = entry.HardLinkTo(targetEntry, startChunk, endChunk)
|
entry = entry.HardLinkTo(targetEntry, startChunk, endChunk)
|
||||||
|
|
||||||
} else if entry.IsHardlinkRoot() {
|
} else if entry.IsHardLinkRoot() {
|
||||||
hardLinkTable = append(hardLinkTable, hardLinkEntry{entry, 0})
|
hardLinkTable = append(hardLinkTable, hardLinkEntry{entry, 0})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -530,21 +530,21 @@ func (entry *Entry) IsComplete() bool {
|
|||||||
return entry.Size >= 0
|
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)
|
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)
|
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() {
|
if entry.IsFile() {
|
||||||
i, err := strconv.ParseUint(entry.Link, 16, 64)
|
i, err := strconv.ParseUint(entry.Link, 16, 64)
|
||||||
return int(i), err
|
return int(i), err
|
||||||
} else {
|
} else {
|
||||||
if entry.EndChunk != entryHardLinkTargetChunkMarker {
|
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
|
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)}
|
k := listEntryLinkKey{dev: uint64(stat.Dev), ino: uint64(stat.Ino)}
|
||||||
if linkIndex, seen := listingState.linkTable[k]; seen {
|
if linkIndex, seen := listingState.linkTable[k]; seen {
|
||||||
if linkIndex == -1 {
|
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
|
continue
|
||||||
}
|
}
|
||||||
entry.Size = 0
|
entry.Size = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user