diff --git a/src/duplicacy_entry.go b/src/duplicacy_entry.go index 1daef9f..14e73ca 100644 --- a/src/duplicacy_entry.go +++ b/src/duplicacy_entry.go @@ -580,11 +580,11 @@ func (entry *Entry) String(maxSizeDigits int) string { return fmt.Sprintf("%*d %s %64s %s", maxSizeDigits, entry.Size, modifiedTime, entry.Hash, entry.Path) } -func (entry *Entry) RestoreMetadata(fullPath string, fileInfo *os.FileInfo, setOwner bool) bool { +func (entry *Entry) RestoreMetadata(fullPath string, fileInfo os.FileInfo, setOwner bool) bool { if fileInfo == nil { - stat, err := os.Lstat(fullPath) - fileInfo = &stat + var err error + fileInfo, err = os.Lstat(fullPath) if err != nil { LOG_ERROR("RESTORE_STAT", "Failed to retrieve the file info: %v", err) return false @@ -603,7 +603,7 @@ func (entry *Entry) RestoreMetadata(fullPath string, fileInfo *os.FileInfo, setO } // Only set the permission if the file is not a symlink - if !entry.IsLink() && (*fileInfo).Mode()&fileModeMask != entry.GetPermissions() { + if !entry.IsLink() && fileInfo.Mode()&fileModeMask != entry.GetPermissions() { err := os.Chmod(fullPath, entry.GetPermissions()) if err != nil { LOG_ERROR("RESTORE_CHMOD", "Failed to set the file permissions: %v", err) @@ -612,7 +612,7 @@ func (entry *Entry) RestoreMetadata(fullPath string, fileInfo *os.FileInfo, setO } // Only set the time if the file is not a symlink - if !entry.IsLink() && (*fileInfo).ModTime().Unix() != entry.Time { + if !entry.IsLink() && fileInfo.ModTime().Unix() != entry.Time { modifiedTime := time.Unix(entry.Time, 0) err := os.Chtimes(fullPath, modifiedTime, modifiedTime) if err != nil { diff --git a/src/duplicacy_utils_others.go b/src/duplicacy_utils_others.go index 3447b62..7907a0b 100644 --- a/src/duplicacy_utils_others.go +++ b/src/duplicacy_utils_others.go @@ -32,8 +32,8 @@ func GetOwner(entry *Entry, fileInfo *os.FileInfo) { } } -func SetOwner(fullPath string, entry *Entry, fileInfo *os.FileInfo) bool { - stat, ok := (*fileInfo).Sys().(*syscall.Stat_t) +func SetOwner(fullPath string, entry *Entry, fileInfo os.FileInfo) bool { + stat, ok := fileInfo.Sys().(*syscall.Stat_t) if ok && stat != nil && (int(stat.Uid) != entry.UID || int(stat.Gid) != entry.GID) { if entry.UID != -1 && entry.GID != -1 { err := os.Lchown(fullPath, entry.UID, entry.GID) diff --git a/src/duplicacy_utils_windows.go b/src/duplicacy_utils_windows.go index cf6414e..0ba8209 100644 --- a/src/duplicacy_utils_windows.go +++ b/src/duplicacy_utils_windows.go @@ -106,7 +106,7 @@ func GetOwner(entry *Entry, fileInfo *os.FileInfo) { entry.GID = -1 } -func SetOwner(fullPath string, entry *Entry, fileInfo *os.FileInfo) bool { +func SetOwner(fullPath string, entry *Entry, fileInfo os.FileInfo) bool { return true }