last modified property handled through http header on PUT rather than PROPPATCH (#438)

This commit is contained in:
Michael Quigley
2024-01-16 13:54:01 -05:00
parent b50f665c93
commit 21df875716
7 changed files with 74 additions and 4 deletions

View File

@@ -205,6 +205,30 @@ func (c *Client) Create(ctx context.Context, name string) (io.WriteCloser, error
return &fileWriter{pw, done}, nil
}
func (c *Client) CreateWithModTime(ctx context.Context, name string, modTime time.Time) (io.WriteCloser, error) {
pr, pw := io.Pipe()
req, err := c.ic.NewRequest(http.MethodPut, name, pr)
if err != nil {
pw.Close()
return nil, err
}
req.Header.Set("Zrok-Modtime", fmt.Sprintf("%d", modTime.Unix()))
done := make(chan error, 1)
go func() {
resp, err := c.ic.Do(req.WithContext(ctx))
if err != nil {
done <- err
return
}
resp.Body.Close()
done <- nil
}()
return &fileWriter{pw, done}, nil
}
func (c *Client) Touch(ctx context.Context, path string, mtime time.Time) error {
status, err := c.ic.Touch(ctx, path, mtime)
if err != nil {