update payload job
This commit is contained in:
parent
94a03fdaa6
commit
6c2b48620a
14
job.go
14
job.go
@ -145,7 +145,7 @@ func setJobPayload(jobID64 int64, payload []byte) error {
|
||||
return errors.New("payload too long")
|
||||
}
|
||||
|
||||
stmt, err := db.Prepare(`UPDATE obj_job j SET j.payload = ? WHERE j.obj_id = ?;`)
|
||||
stmt, err := db.Prepare(`UPDATE obj_job j SET j.payload = ?, j.zipped = 1 WHERE j.obj_id = ?;`)
|
||||
logOnError(err, "setJobTimeout : prepare update obj_job")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -227,6 +227,7 @@ func loadCurrentJobs() ([]Job, error) {
|
||||
userID64 int64
|
||||
trigger int64
|
||||
timeout time.Time
|
||||
zipped int
|
||||
zpayload []byte
|
||||
jobs []Job
|
||||
)
|
||||
@ -240,7 +241,7 @@ func loadCurrentJobs() ([]Job, error) {
|
||||
return jobs, err
|
||||
}
|
||||
|
||||
stmt, err := db.Prepare("SELECT o.id, o.obj_sub_type_id, j.trigger_id, j.user_id, j.payload, j.timeout FROM obj_job j, obj o WHERE j.obj_id = o.id AND j.is_done = 0 AND j.in_work = 1 AND j.seq_nr = ? ORDER BY j.priority ASC, j.obj_id ASC;")
|
||||
stmt, err := db.Prepare("SELECT o.id, o.obj_sub_type_id, j.trigger_id, j.user_id, j.zipped, j.payload, j.timeout FROM obj_job j, obj o WHERE j.obj_id = o.id AND j.is_done = 0 AND j.in_work = 1 AND j.seq_nr = ? ORDER BY j.priority ASC, j.obj_id ASC;")
|
||||
logOnError(err, "loadCurrentJobs : prepare select statement")
|
||||
if err != nil {
|
||||
stmt.Close()
|
||||
@ -256,9 +257,11 @@ func loadCurrentJobs() ([]Job, error) {
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
err = rows.Scan(&objId, &jobTypeID64, &trigger, &userID64, &zpayload, &timeout)
|
||||
err = rows.Scan(&objId, &jobTypeID64, &trigger, &userID64, &zipped, &zpayload, &timeout)
|
||||
logOnError(err, "loadCurrentJobs : scan query rows")
|
||||
|
||||
var payload []byte
|
||||
if zipped > 0 {
|
||||
zb := bytes.NewReader(zpayload)
|
||||
zr, err := zlib.NewReader(zb)
|
||||
if err != nil {
|
||||
@ -267,7 +270,10 @@ func loadCurrentJobs() ([]Job, error) {
|
||||
}
|
||||
b := new(bytes.Buffer)
|
||||
b.ReadFrom(zr)
|
||||
payload := b.Bytes()
|
||||
payload = b.Bytes()
|
||||
} else {
|
||||
payload = zpayload
|
||||
}
|
||||
|
||||
job := Job{
|
||||
ID64: objId,
|
||||
|
Loading…
Reference in New Issue
Block a user