You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
commands/files: Make Stat() part of the File interface
We need Stat() calls to figure out whether a file is a directory,
regular file, or other object (e.g. a symlink, named pipe, etc.).
This commit shifts our File interface to more closely match os.File.
I'm a bit concerned that the backing Stat calls on any underlying
os.File is done at wrapper-creation time and not at wrapper.Stat()
time. That means we'll get stale data with a workflow like:
1. Create a new commands/files/... File (e.g. via NewSerialFile)
2. Edit the backing file (e.g. appending data to it).
3. Call f.Stat() on our wrapping file to get a FileInfo type.
In that case, fi.Size() and fi.ModTime() on the returned FileInfo from
(3) will reflect the values that the file had at (1), and not the
values that it should have at (3). Maybe we're mostly using our File
wrappers as read- or write-only entities and then throwing them away,
in which case this discrepancy may not be too important. But it's
still a race hole I'd like to close.
License: MIT
Signed-off-by: W. Trevor King <wking@tremily.us>
0 commit comments