Skip to content

Commit

Permalink
revert removal of early upload finish for all fs
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek committed Nov 25, 2021
1 parent 9077254 commit dfd3916
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/storage/fs/owncloud/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ func (fs *ocfs) NewUpload(ctx context.Context, info tusd.FileInfo) (upload tusd.
ctx: ctx,
}

if !info.SizeIsDeferred && info.Size == 0 {
log.Debug().Interface("info", info).Msg("ocfs: finishing upload for empty file")
// no need to create info file and finish directly
err := u.FinishUpload(ctx)
if err != nil {
return nil, err
}
return u, nil
}

// writeInfo creates the file by itself if necessary
err = u.writeInfo()
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/storage/fs/owncloudsql/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ func (fs *owncloudsqlfs) NewUpload(ctx context.Context, info tusd.FileInfo) (upl
ctx: ctx,
}

if !info.SizeIsDeferred && info.Size == 0 {
log.Debug().Interface("info", info).Msg("owncloudsql: finishing upload for empty file")
// no need to create info file and finish directly
err := u.FinishUpload(ctx)
if err != nil {
return nil, err
}
return u, nil
}

// writeInfo creates the file by itself if necessary
err = u.writeInfo()
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/storage/utils/decomposedfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,16 @@ func (fs *Decomposedfs) NewUpload(ctx context.Context, info tusd.FileInfo) (uplo
ctx: ctx,
}

if !info.SizeIsDeferred && info.Size == 0 {
log.Debug().Interface("info", info).Msg("Decomposedfs: finishing upload for empty file")
// no need to create info file and finish directly
err := u.FinishUpload(ctx)
if err != nil {
return nil, err
}
return u, nil
}

// writeInfo creates the file by itself if necessary
err = u.writeInfo()
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/storage/utils/localfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ func (fs *localfs) NewUpload(ctx context.Context, info tusd.FileInfo) (upload tu
ctx: ctx,
}

if !info.SizeIsDeferred && info.Size == 0 {
log.Debug().Interface("info", info).Msg("localfs: finishing upload for empty file")
// no need to create info file and finish directly
err := u.FinishUpload(ctx)
if err != nil {
return nil, err
}
return u, nil
}

// writeInfo creates the file by itself if necessary
err = u.writeInfo()
if err != nil {
Expand Down

0 comments on commit dfd3916

Please sign in to comment.