Investigate potential bug in Writer() method

The writer method does something really weird here:

https://gitlab.com/gitlab-org/container-registry/-/blob/757268f89d8b5370656a7eee91d4eb69462797ae/registry/storage/driver/gcs/gcs.go#L671-678

The size of the buffer if fixed. We read only the first n bytes of the existing object into this buffer and then append new data to this buffer. Why does this work even when the object that we are appending to is larger than the buffer. In theory we should loose the data between the size of the buffer and the end of the object we are appending to.

I would like to get good understanding why before we continue working on the driver. Either I am missing something or there is a bug lurking in here.

Edited Apr 17, 2025 by Pawel Rozlach
Assignee Loading
Time tracking Loading