diff --git a/pkg/rhttp/datatx/manager/tus/tus.go b/pkg/rhttp/datatx/manager/tus/tus.go index e868569a311..c2d49c1ca2c 100644 --- a/pkg/rhttp/datatx/manager/tus/tus.go +++ b/pkg/rhttp/datatx/manager/tus/tus.go @@ -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 { diff --git a/pkg/storage/uploads.go b/pkg/storage/uploads.go index 4fcc69a7d2d..4e70e0114ac 100644 --- a/pkg/storage/uploads.go +++ b/pkg/storage/uploads.go @@ -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 @@ -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) } @@ -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 { diff --git a/pkg/storage/utils/decomposedfs/upload.go b/pkg/storage/utils/decomposedfs/upload.go index 8af40e4add2..f546ae6d250 100644 --- a/pkg/storage/utils/decomposedfs/upload.go +++ b/pkg/storage/utils/decomposedfs/upload.go @@ -273,7 +273,6 @@ func (fs *Decomposedfs) ListUploadSessions(ctx context.Context, filter storage.U if now.After(session.Expires()) { continue } - } } filteredSessions = append(filteredSessions, session) @@ -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 } diff --git a/pkg/storage/utils/decomposedfs/upload/processing.go b/pkg/storage/utils/decomposedfs/upload/processing.go index 71ac7eaa9a4..f47bc196e9f 100644 --- a/pkg/storage/utils/decomposedfs/upload/processing.go +++ b/pkg/storage/utils/decomposedfs/upload/processing.go @@ -502,8 +502,6 @@ type Progress struct { Path string Info tusd.FileInfo Processing bool - ScanStatus string - ScanTime time.Time } func (p Progress) ID() string { @@ -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 {