improve detection of relative links
This commit is contained in:
parent
297c9e2f7a
commit
fff1c0ae57
@ -370,9 +370,17 @@ func (b *Blockstore) movingGC() error {
|
|||||||
// symlink creates a symlink from path to linkPath; the link is relative if the two are
|
// symlink creates a symlink from path to linkPath; the link is relative if the two are
|
||||||
// in the same directory
|
// in the same directory
|
||||||
func (b *Blockstore) symlink(path, linkTo string) error {
|
func (b *Blockstore) symlink(path, linkTo string) error {
|
||||||
pathDir := filepath.Dir(path)
|
resolvedPathDir, err := filepath.EvalSymlinks(filepath.Dir(path))
|
||||||
linkDir := filepath.Dir(linkTo)
|
if err != nil {
|
||||||
if pathDir == linkDir {
|
return fmt.Errorf("error resolving links in %s: %w", path, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvedLinkDir, err := filepath.EvalSymlinks(filepath.Dir(linkTo))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error resolving links in %s: %W", linkTo, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resolvedPathDir == resolvedLinkDir {
|
||||||
path = filepath.Base(path)
|
path = filepath.Base(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user