Open opens the file for read. Call Close() on the returned io.ReadCloser Remember this is called multiple times whenever the backend seeks (eg having read checksum)
(ctx context.Context, options ...fs.OpenOption)
| 253 | // |
| 254 | // Remember this is called multiple times whenever the backend seeks (eg having read checksum) |
| 255 | func (o errorObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) { |
| 256 | fs.Debugf(nil, "Open with options = %v", options) |
| 257 | rc, err := o.Object.Open(ctx, options...) |
| 258 | if err != nil { |
| 259 | return nil, err |
| 260 | } |
| 261 | // Return an error reader for the second segment |
| 262 | for _, option := range options { |
| 263 | if ropt, ok := option.(*fs.RangeOption); ok { |
| 264 | end := ropt.End + 1 |
| 265 | if end >= o.size { |
| 266 | // Give the other chunks a chance to start |
| 267 | time.Sleep(time.Second) |
| 268 | // Wait for chunks to upload first |
| 269 | o.wg.Wait() |
| 270 | fs.Debugf(nil, "Returning error reader") |
| 271 | return errorReadCloser{rc}, nil |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | o.wg.Add(1) |
| 276 | return wgReadCloser{rc, o.wg}, nil |
| 277 | } |
| 278 | |
| 279 | type errorReadCloser struct { |
| 280 | io.ReadCloser |