short-circuit File.Sync if not supported

This commit is contained in:
Cassondra Foesch 2025-02-27 13:51:25 +00:00
parent fb0652cf58
commit a2172dc0b9
1 changed files with 7 additions and 0 deletions

View File

@ -2122,6 +2122,13 @@ func (f *File) Sync() error {
return os.ErrClosed return os.ErrClosed
} }
if data, ok := f.c.HasExtension(openssh.ExtensionFSync().Name); !ok || data != "1" {
return &StatusError{
Code: sshFxOPUnsupported,
msg: "fsync not supported",
}
}
id := f.c.nextID() id := f.c.nextID()
typ, data, err := f.c.sendPacket(context.Background(), nil, &sshFxpFsyncPacket{ typ, data, err := f.c.sendPacket(context.Background(), nil, &sshFxpFsyncPacket{
ID: id, ID: id,