Skip to content

Commit

Permalink
incorporate feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Nov 30, 2023
1 parent 69ec64f commit 670b4c2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pkg/rhttp/datatx/manager/tus/tus.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) {
return nil, err
}

if _, ok := fs.(storage.UploadsManager); ok {
if _, ok := fs.(storage.UploadSessionLister); ok {
// TODO we can currently only send updates if the fs is decomposedfs as we read very specific keys from the storage map of the tus info
go func() {
for {
Expand Down
16 changes: 10 additions & 6 deletions pkg/storage/uploads.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
tusd "github.com/tus/tusd/pkg/handler"
)

// UploadFinishedFunc is a callback function used in storage drivers to indicate that an upload has finished
Expand All @@ -36,8 +37,15 @@ type UploadRequest struct {
Length int64
}

// UploadsManager defines the interface for FS implementations that allow for managing uploads
// UploadsManager defines the interface for storage drivers that allow for managing uploads
// Deprecated: No longer used. Storage drivers should implement the UploadSessionLister.
type UploadsManager interface {
ListUploads() ([]tusd.FileInfo, error)
PurgeExpiredUploads(chan<- tusd.FileInfo) error
}

// UploadSessionLister defines the interface for FS implementations that allow listing and purging upload sessions
type UploadSessionLister interface {
// GetUploadProgress returns the upload progress
ListUploadSessions(ctx context.Context, filter UploadSessionFilter) ([]UploadSession, error)
}
Expand All @@ -63,13 +71,9 @@ type UploadSession interface {
// IsProcessing returns true if postprocessing has not finished, yet
// The actual postprocessing state is tracked in the postprocessing service.
IsProcessing() bool
// MalwareDescription returns the scan result returned by the scanner
MalwareDescription() string
// MalwareScanTime returns the timestamp the upload was scanned. Default time means the item has not been scanned
MalwareScanTime() time.Time

// Purge allows completely removing an upload. Should emit a PostprocessingFinished event with a Delete outcome
Purge() error
Purge(ctx context.Context) error
}

type UploadSessionFilter struct {
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/utils/decomposedfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ func (fs *Decomposedfs) ListUploadSessions(ctx context.Context, filter storage.U
if now.After(session.Expires()) {
continue
}

}
}
filteredSessions = append(filteredSessions, session)
Expand Down Expand Up @@ -344,6 +343,5 @@ func (fs *Decomposedfs) getUploadProgress(ctx context.Context, path string) (sto
Info: info,
Processing: n.IsProcessing(ctx),
}
_, progress.ScanStatus, progress.ScanTime = n.ScanData(ctx)
return progress, nil
}
10 changes: 1 addition & 9 deletions pkg/storage/utils/decomposedfs/upload/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,6 @@ type Progress struct {
Path string
Info tusd.FileInfo
Processing bool
ScanStatus string
ScanTime time.Time
}

func (p Progress) ID() string {
Expand Down Expand Up @@ -548,14 +546,8 @@ func (p Progress) Expires() time.Time {
func (p Progress) IsProcessing() bool {
return p.Processing
}
func (p Progress) MalwareDescription() string {
return p.ScanStatus
}
func (p Progress) MalwareScanTime() time.Time {
return p.ScanTime
}

func (p Progress) Purge() error {
func (p Progress) Purge(ctx context.Context) error {
// TODO we should use the upload id to look up the tus upload and Terminate() that
err := os.Remove(p.Info.Storage["BinPath"])
if err != nil {
Expand Down

0 comments on commit 670b4c2

Please sign in to comment.