mirror of
https://github.com/rclone/rclone.git
synced 2025-08-15 00:02:35 +02:00
local: continue listing files/folders when a circular symlink is detected
Before this change a circular symlink would cause rclone to error out from the listings. After this change rclone will skip a circular symlink and carry on the listing, producing an error at the end. Fixes #4743
This commit is contained in:
22
backend/local/symlink.go
Normal file
22
backend/local/symlink.go
Normal file
@ -0,0 +1,22 @@
|
||||
// +build !windows,!plan9,!js
|
||||
|
||||
package local
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// isCircularSymlinkError checks if the current error code is because of a circular symlink
|
||||
func isCircularSymlinkError(err error) bool {
|
||||
if err != nil {
|
||||
if newerr, ok := err.(*os.PathError); ok {
|
||||
if errcode, ok := newerr.Err.(syscall.Errno); ok {
|
||||
if errcode == syscall.ELOOP {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user