Skip to content

Commit 45f62cd

Browse files
committed
fix: Debug logs to trigger antivirus job
1 parent 66a1d92 commit 45f62cd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

model/job/trigger_antivirus.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ func NewAntivirusTrigger(broker Broker) *AntivirusTrigger {
3030

3131
// Schedule starts listening for file creation and update events.
3232
func (t *AntivirusTrigger) Schedule() {
33+
t.log.Infof("trigger antivirus: Starting antivirus trigger, subscribing to firehose")
3334
sub := realtime.GetHub().SubscribeFirehose()
3435
defer sub.Close()
3536
for {
3637
select {
3738
case e := <-sub.Channel:
3839
if t.match(e) {
40+
t.log.Debugf("trigger antivirus: matched event for domain %s, doctype %s", e.Domain, e.Doc.DocType())
3941
t.pushJob(e)
4042
}
4143
case <-t.unscheduled:
44+
t.log.Infof("trigger antivirus: Stopping antivirus trigger")
4245
return
4346
}
4447
}
@@ -93,19 +96,28 @@ func (t *AntivirusTrigger) hasContentChanged(e *realtime.Event) bool {
9396
}
9497

9598
func (t *AntivirusTrigger) pushJob(e *realtime.Event) {
99+
t.log.Debugf("trigger antivirus: received event for domain %s, doctype %s, verb %s", e.Domain, e.Doc.DocType(), e.Verb)
100+
96101
// Get instance to check if antivirus is enabled
97102
inst, err := instance.Get(e.Domain)
98103
if err != nil {
104+
t.log.Errorf("trigger antivirus: could not get instance %s: %v", e.Domain, err)
99105
return
100106
}
101107

102108
cfg := config.GetAntivirusConfig(inst.ContextName)
103-
if cfg == nil || !cfg.Enabled {
109+
if cfg == nil {
110+
t.log.Debugf("trigger antivirus: no config for context %s", inst.ContextName)
111+
return
112+
}
113+
if !cfg.Enabled {
114+
t.log.Debugf("trigger antivirus: disabled for context %s", inst.ContextName)
104115
return
105116
}
106117

107118
doc, ok := e.Doc.(*vfs.FileDoc)
108119
if !ok {
120+
t.log.Debugf("trigger antivirus: event doc is not a FileDoc, type: %T", e.Doc)
109121
return
110122
}
111123

0 commit comments

Comments
 (0)