tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
2.93k stars 465 forks source link

Uniform Termination Process for Store Implementations: Ensuring Consistent Removal of Binary and .info Files #1075

Open DarioCalovic opened 5 months ago

DarioCalovic commented 5 months ago

Describe the bug Issueing the termination process the filestore removes both the binary as well as the .info file. The gcc store only removes the binary file.

To Reproduce The .info is being ignored explicit: https://github.com/tus/tusd/blob/main/pkg/gcsstore/gcsservice.go#L355

func (service *GCSService) FilterObjects(ctx context.Context, params GCSFilterParams) ([]string, error) {

# ...

  if strings.HasSuffix(objAttrs.Name, "info") {
    continue
  }

# ...

Expected behavior The expected behavior is that all store implementations, including the GCS store, should uniformly handle the terminating process by removing both the binary files and their corresponding .info files. The termination process should be consistent across different store implementations to ensure a standardized and predictable behavior.

Acconut commented 5 months ago

Good catch! FilterObjects has been designed to find objects in a bucket which should be composed to form the final object. The .info should not be included here and is thus explicitly removed from the list. For terminating the upload, this behavior is not wanted, as you correctly found.

A solution would be to add an object IncludeInfoObject to GCSFilterParams, which can be set by the termination code to instruct FilterObjects to not exclude .info objects. Would you be interested in opening a PR for this?