mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
Implements rollout steps 1 and 2 of proposals/274-skillfollow.md. Nothing follows a link or parses .skillfollow yet. Step 1: doctor reports first-level symlinks and junctions in the skills source as info, in text and JSON, without following them. Step 2a: internal/sourcewalk owns traversal of the skills source. Thirteen raw walks move onto it with identical behavior, and a go/parser ratchet fails the tests on any new unclassified walk. Step 2b: internal/sourcefs wraps an os.Root opened at the skills source and refuses any write whose path has a link component. The six write sites the proposal found in review move onto it, including the cross-device copy fallback, and a second ratchet covers raw os write calls. The only behavior change is that an explicit path crossing a link inside the source is refused instead of written through. Refs #274 Release-As: 0.24.3
23 lines
559 B
Go
23 lines
559 B
Go
package sourcefs
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestIsCrossDeviceMatchesOnlyRenameAcrossFilesystems(t *testing.T) {
|
|
if IsCrossDevice(&os.LinkError{Op: "rename", Old: "a", New: "b", Err: crossDeviceErrno}) != true {
|
|
t.Fatal("a wrapped cross-device errno must match")
|
|
}
|
|
for name, err := range map[string]error{
|
|
"link refusal": &LinkError{Path: "/src/_f"},
|
|
"exists": errors.New("/src/a already exists"),
|
|
"not exist": os.ErrNotExist,
|
|
} {
|
|
if IsCrossDevice(err) {
|
|
t.Fatalf("%s must not count as cross-device", name)
|
|
}
|
|
}
|
|
}
|