33 lines
682 B
Go
33 lines
682 B
Go
package jobs
|
|
|
|
import (
|
|
"time"
|
|
|
|
"ddc/internal/history"
|
|
)
|
|
|
|
func (manager *Manager) History() []history.Entry {
|
|
return manager.history.List()
|
|
}
|
|
|
|
func (manager *Manager) ClearHistory() error {
|
|
return manager.history.Clear()
|
|
}
|
|
|
|
func (manager *Manager) recordHistory(job *Job, destination string, movedNames []string) {
|
|
if len(movedNames) == 0 {
|
|
return
|
|
}
|
|
snapshot := job.snapshot()
|
|
entry := history.Entry{
|
|
FileName: snapshot.FileName,
|
|
SourceURL: snapshot.SourceURL,
|
|
Destination: destination,
|
|
Items: movedNames,
|
|
MovedAt: time.Now(),
|
|
}
|
|
if err := manager.history.Add(entry); err != nil {
|
|
job.logger().Error("could not save history", "error", err)
|
|
}
|
|
}
|