- if err == nil && !s.opts.LeaveIncompleteChunks {
- // I think we do this synchronously here since we don't want callers to act on the completed
- // piece if we're concurrently still deleting chunks. The caller may decide to start
- // downloading chunks again and won't expect us to delete them. It seems to be much faster
- // to let the resource provider do this if possible.
+ if err != nil || s.opts.LeaveIncompleteChunks {
+ return
+ }
+
+ // I think we do this synchronously here since we don't want callers to act on the completed
+ // piece if we're concurrently still deleting chunks. The caller may decide to start
+ // downloading chunks again and won't expect us to delete them. It seems to be much faster
+ // to let the resource provider do this if possible.
+ if pd, ok := s.rp.(PrefixDeleter); ok {
+ err = pd.DeletePrefix(s.incompleteDirPath() + "/")
+ if err != nil {
+ err = fmt.Errorf("deleting incomplete prefix: %w", err)
+ }
+ } else {