Specify the behavior for writing empty file

Code like the following could hang forever (tested on go-service-s3)

_, err = fs.s.Write(path,nil, 0)
if err != nil {
    fs.logger.Error("write", zap.String("path", path), zap.Error(err))
    return nil, nil, err
}

I have to write it like:

_, err = fs.s.Write(path, bytes.NewReader([]byte{}), 0)
if err != nil {
    fs.logger.Error("write", zap.String("path", path), zap.Error(err))
    return nil, nil, err
}

Maybe we can support user input nil Reader for empty files?

In order to add this support, we need to:

  • Add a new GSP to make it clear
  • Update definitions to reflect changes
  • Update integrations tests to make sure all service passed

GSP-751: Write Empty File Behavior by abyss-w · Pull Request #751 · beyondstorage/go-storage · GitHub proposed.

The GSP GSP-751: Write Empty File Behavior by abyss-w · Pull Request #751 · beyondstorage/go-storage · GitHub has been approved.

@abyss-w is working on this issue: Tracking issue of GSP-751: Write Empty File Behavior · Issue #756 · beyondstorage/go-storage · GitHub

Seems that not all services support writing empty file, like OneDrive.

Maybe we should add the expected behavior when writing an empty file is not supported based on the current GSP-751: Write Empty File Behavior?

This may add extra burden of go-integration-tests. I’m thinking about introdcing feature flags.