Skip to content

Commit

Permalink
Make a new interface for direct SetStat access.
Browse files Browse the repository at this point in the history
I'm really not especially happy with this.

It works, it's minimally invasive, and it feels like the wrong solution.

I'm pretty sure that the right solution is a breaking change of the
Request structure, to just flat out contain FileAttrFlags and FileStat,
having requestFromPacket do the parsing into those structures.

But that's an API change, and I doubt that we want a major version bump
for this.

As an alternative, we could have a new Request structure type, with that
layout, and have public functions for converting between them.

That would at least make it possible for someone to construct the
Request structure for a Setstat command.

The use case of this is being able to populate a memfile backed sftp
server with test data that has specific timestamps, as part of the test
framework of an internal program.

I'm definitely open to other ideas on how to solve this problem.
  • Loading branch information
Zeph / Liz Loss-Cutler-Hull committed Oct 31, 2023
1 parent 07a6b6a commit 7bf7a25
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions request-interfaces.go
Expand Up @@ -155,3 +155,9 @@ type ListerAt interface {
type TransferError interface {
TransferError(err error)
}

// FileStatSetter is an optional interface that a writerAt could implement in order to allow direct setting of stats.
// This is primarily used for the inmemhandler backend.
type FileStatSetter interface {
SetStat(r *Request, flags *FileAttrFlags, attrs *FileStat) error
}

0 comments on commit 7bf7a25

Please sign in to comment.