Skip to content

Commit

Permalink
Add warning comments around the Extended logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeph / Liz Loss-Cutler-Hull committed Nov 3, 2023
1 parent 1ae2738 commit 3d7324a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions attrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ func (fs FileStat) MarshalTo(b []byte, flags FileAttrFlags) []byte {
b = marshalUint32(b, fs.Mtime)
}

// NOTE: This is subtle, this logic must not be changed without also changing the login in fileStatFromInfo.
// The rules on how sshFileXferAttrExtended gets set must match the rules on how we generate the packet.
if len(fs.Extended) > 0 {
b = marshalUint32(b, uint32(len(fs.Extended)))

Expand Down Expand Up @@ -151,6 +153,9 @@ func fileStatFromInfo(fi os.FileInfo) (uint32, *FileStat) {
fileStat.GID = fiExt.Gid()
}

// NOTE: This is subtle, this logic must not be changed without also changing the login in marshalTo.
// The rules on how sshFileXferAttrExtended gets set must match the rules on how we generate the packet.
//
// if fi implements FileInfoExtendedData, retrieve extended data from it
if fiExt, ok := fi.(FileInfoExtendedData); ok {
fileStat.Extended = fiExt.Extended()
Expand Down

0 comments on commit 3d7324a

Please sign in to comment.