Logo
Explore Help
Sign In
TheArchive/restic
1
0
Fork 0
You've already forked restic
mirror of https://github.com/restic/restic.git synced 2025-05-10 23:56:48 +00:00
Code Issues Packages Projects Releases Wiki Activity
restic/internal/fs/node_unix_notlinux.go

22 lines
436 B
Go
Raw Normal View History

fs: Refactor UtimesNano replacements Previously, nodeRestoreTimestamps would do something like if node.Type == restic.NodeTypeSymlink { return nodeRestoreSymlinkTimestamps(...) } return syscall.UtimesNano(...) where nodeRestoreSymlinkTimestamps was either a no-op or a reimplementation of syscall.UtimesNano that handles symlinks, with some repeated converting between timestamp types. The Linux implementation was a bit clumsy, requiring three syscalls to set the timestamps. In this new setup, there is a function utimesNano that has three implementations: * on Linux, it's a modified syscall.UtimesNano that uses AT_SYMLINK_NOFOLLOW and AT_FDCWD so it can handle any type in a single call; * on other Unix platforms, it just calls the syscall function after skipping symlinks; * on Windows, it's the modified UtimesNano that was previously called nodeRestoreSymlinkTimestamps, except with different arguments.
2024-10-04 10:06:18 +02:00
//go:build !linux && unix
package fs
import (
"syscall"
"github.com/restic/restic/internal/restic"
)
// utimesNano is like syscall.UtimesNano, except that it skips symlinks.
func utimesNano(path string, atime, mtime int64, typ restic.NodeType) error {
if typ == restic.NodeTypeSymlink {
return nil
}
return syscall.UtimesNano(path, []syscall.Timespec{
syscall.NsecToTimespec(atime),
syscall.NsecToTimespec(mtime),
})
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.6 Page: 2533ms Template: 5ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API