examples: Fix OCI tempfile garbage
Close the imagefs.FS
at the end of every scenario to ensure its
temporary directory is removed.
Fixed a bug caused by the return of a new imagefs.lazyFS
pointer in
lazyFS.WithContext
when the underlying FS has not yet been
initialized. Since there is a no real FS pointer in that case, the
initialization of the real underlying filesystem is effectively lost
between calls to WithContext
, resulting in orphaned FS objects for
every call to Open
and no garbage collection of the temporary files
created by each initialization, not to mention tons of duplicate
initialization and wasted resources.
Fixing the above bug surfaced another bug in imagefs
where tar files
could only be read once. This was fixed by creating a new bytes.Reader
upon each call to Open
for the given file.
Bug: T365285