Ensure nil is accepted as FS config (#1182)
In previous releases, passing a `nil` value as an FS config
did not cause any error. However, in 1.0.0-rc.1 this leads
to the creation of an invalid `adapter{fs: nil}`, which
eventually leads to a panic (nil):
(f *FileEntry) Stat(st *platform.Stat_t) =>
(r *lazyDir) file() =>
r.fs.OpenFile(".", os.O_RDONLY, 0)
with fs == nil
The backwards-compatible fix is to make Adapt()
return UnimplementedFS, and ensuring `nil` is a valid value
that config is able to handle.
However, we may want to consider returning an error somewhere,
because configuring a nil FS may be unintended.
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
This commit is contained in:
@@ -35,6 +35,11 @@ func TestFSConfig(t *testing.T) {
|
||||
input: base.WithFSMount(testFS, "/").WithFSMount(testFS2, "/"),
|
||||
expected: sysfs.Adapt(testFS2),
|
||||
},
|
||||
{
|
||||
name: "WithFsMount nil",
|
||||
input: base.WithFSMount(nil, "/"),
|
||||
expected: sysfs.UnimplementedFS{},
|
||||
},
|
||||
{
|
||||
name: "WithDirMount overwrites",
|
||||
input: base.WithFSMount(testFS, "/").WithDirMount(".", "/"),
|
||||
|
||||
Reference in New Issue
Block a user