mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 03:40:01 -06:00
better configuration for pp service
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/owncloud/ocis/v2/services/postprocessing/pkg/config"
|
||||
)
|
||||
|
||||
// Postprocessing handles postprocessing of a file
|
||||
@@ -18,22 +17,22 @@ type Postprocessing struct {
|
||||
filename string
|
||||
filesize uint64
|
||||
resourceID *provider.ResourceId
|
||||
c config.Postprocessing
|
||||
steps []events.Postprocessingstep
|
||||
delay time.Duration
|
||||
}
|
||||
|
||||
// New returns a new postprocessing instance
|
||||
func New(uploadID string, uploadURL string, user *user.User, filename string, filesize uint64, resourceID *provider.ResourceId, c config.Postprocessing) *Postprocessing {
|
||||
func New(uploadID string, uploadURL string, user *user.User, filename string, filesize uint64, resourceID *provider.ResourceId, steps []events.Postprocessingstep, delay time.Duration) *Postprocessing {
|
||||
return &Postprocessing{
|
||||
id: uploadID,
|
||||
url: uploadURL,
|
||||
u: user,
|
||||
m: make(map[events.Postprocessingstep]interface{}),
|
||||
c: c,
|
||||
filename: filename,
|
||||
filesize: filesize,
|
||||
resourceID: resourceID,
|
||||
steps: getSteps(c),
|
||||
steps: steps,
|
||||
delay: delay,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +63,7 @@ func (pp *Postprocessing) Virusscan(ev events.VirusscanFinished) interface{} {
|
||||
// Delay will sleep the configured time then continue
|
||||
func (pp *Postprocessing) Delay(ev events.StartPostprocessingStep) interface{} {
|
||||
pp.m[events.PPStepDelay] = ev
|
||||
time.Sleep(pp.c.Delayprocessing)
|
||||
time.Sleep(pp.delay)
|
||||
return pp.next(events.PPStepDelay)
|
||||
}
|
||||
|
||||
@@ -99,20 +98,3 @@ func (pp *Postprocessing) finished(outcome events.PostprocessingOutcome) events.
|
||||
Outcome: outcome,
|
||||
}
|
||||
}
|
||||
|
||||
func getSteps(c config.Postprocessing) []events.Postprocessingstep {
|
||||
// NOTE: first version only contains very basic configuration options
|
||||
// But we aim for a system where postprocessing steps and their order can be configured per space
|
||||
// ideally by the spaceadmin itself
|
||||
// We need to iterate over configuring PP service when we see fit
|
||||
var steps []events.Postprocessingstep
|
||||
if c.Delayprocessing != 0 {
|
||||
steps = append(steps, events.PPStepDelay)
|
||||
}
|
||||
|
||||
if c.Virusscan {
|
||||
steps = append(steps, events.PPStepAntivirus)
|
||||
}
|
||||
|
||||
return steps
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user