mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-10-09 12:22:04 -04:00
Point the go-micro.dev/v4 replace at the latest main-v4 maintenance branch commit in butonic/go-micro (cd412c15) instead of the v4.11.3 tag. The new base is upstream v4.11.1 plus the registry cache node-TTL fixes (upstream #2715, #2736, #2740), the concurrent map access fix (upstream #2794), plus further dependency updates and test fixes on the maintenance branch. The branch also modernizes go-micro's own go.mod (go 1.26, lego, dario.cat/mergo v1, x/deque v2, ...), and MVS pulls the aligned versions into this module: lego v4.35.2 -> lego/v5 v5.5.2, go-jose/go-jose/v4 -> v4.1.5, gofrs/flock -> v0.13.1, mattn/go-isatty -> v0.0.24, go.uber.org/zap -> v1.28.0, x/net -> 0.59.0, miekg/dns -> 1.1.73, moby api/client, ProtonMail/go-crypto -> 1.5.2, klauspost/compress -> 1.20.1, gorilla/handlers -> 1.5.2, gobwas/ws -> 1.4.0, nxadm/tail -> 1.4.11, ... Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
96 lines
1.9 KiB
Go
96 lines
1.9 KiB
Go
//go:build !linux
|
|
|
|
package archive
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
func collectFileInfoForChanges(oldDir, newDir string) (*FileInfo, *FileInfo, error) {
|
|
var (
|
|
oldRoot, newRoot *FileInfo
|
|
err1, err2 error
|
|
errs = make(chan error, 2)
|
|
)
|
|
go func() {
|
|
oldRoot, err1 = collectFileInfo(oldDir)
|
|
errs <- err1
|
|
}()
|
|
go func() {
|
|
newRoot, err2 = collectFileInfo(newDir)
|
|
errs <- err2
|
|
}()
|
|
|
|
// block until both routines have returned
|
|
for range 2 {
|
|
if err := <-errs; err != nil {
|
|
return nil, nil, err
|
|
}
|
|
}
|
|
|
|
return oldRoot, newRoot, nil
|
|
}
|
|
|
|
func collectFileInfo(sourceDir string) (*FileInfo, error) {
|
|
root := newRootFileInfo()
|
|
|
|
err := filepath.WalkDir(sourceDir, func(path string, _ os.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Rebase path
|
|
relPath, err := filepath.Rel(sourceDir, path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// As this runs on the daemon side, file paths are OS specific.
|
|
relPath = filepath.Join(string(os.PathSeparator), relPath)
|
|
|
|
// See https://github.com/golang/go/issues/9168 - bug in filepath.Join.
|
|
// Temporary workaround. If the returned path starts with two backslashes,
|
|
// trim it down to a single backslash. Only relevant on Windows.
|
|
if runtime.GOOS == "windows" {
|
|
if strings.HasPrefix(relPath, `\\`) {
|
|
relPath = relPath[1:]
|
|
}
|
|
}
|
|
|
|
if relPath == string(os.PathSeparator) {
|
|
return nil
|
|
}
|
|
|
|
parent := root.LookUp(filepath.Dir(relPath))
|
|
if parent == nil {
|
|
return fmt.Errorf("collectFileInfo: Unexpectedly no parent for %s", relPath)
|
|
}
|
|
|
|
s, err := os.Lstat(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
info := &FileInfo{
|
|
name: filepath.Base(relPath),
|
|
children: make(map[string]*FileInfo),
|
|
parent: parent,
|
|
stat: s,
|
|
}
|
|
|
|
info.capability, _ = lgetxattr(path, "security.capability")
|
|
|
|
parent.children[info.name] = info
|
|
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return root, nil
|
|
}
|