Merge pull request #576 from stevvooe/seek-reset-handling
content: allow reset via Truncate
This commit is contained in:
commit
317b884110
7 changed files with 64 additions and 13 deletions
|
@ -195,6 +195,8 @@ func (s *Service) Write(session api.Content_WriteServer) (err error) {
|
|||
}
|
||||
|
||||
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(fields))
|
||||
|
||||
log.G(ctx).Debug("(*Service).Write started")
|
||||
// this action locks the writer for the session.
|
||||
wr, err := s.store.Writer(ctx, ref, total, expected)
|
||||
if err != nil {
|
||||
|
@ -266,6 +268,13 @@ func (s *Service) Write(session api.Content_WriteServer) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
if req.Offset == 0 && ws.Offset > 0 {
|
||||
if err := wr.Truncate(req.Offset); err != nil {
|
||||
return errors.Wrapf(err, "truncate failed")
|
||||
}
|
||||
msg.Offset = req.Offset
|
||||
}
|
||||
|
||||
// issue the write if we actually have data.
|
||||
if len(req.Data) > 0 {
|
||||
// While this looks like we could use io.WriterAt here, because we
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue