This commit is contained in:
shoopea 2020-01-26 14:47:29 +08:00
parent 2f168b12e9
commit 82842714e7

20
job.go
View File

@ -147,28 +147,30 @@ func setJobTimeout(jobID64 int64, d time.Duration) error {
func setJobPayload(jobID64 int64, payload []byte) error { func setJobPayload(jobID64 int64, payload []byte) error {
var zb bytes.Buffer var zb bytes.Buffer
if len(payload) > 10000 {
zw := zlib.NewWriter(&zb) zw := zlib.NewWriter(&zb)
zw.Write(payload) zw.Write(payload)
zw.Close() zw.Close()
zpayload := zb.Bytes() zpayload = zb.Bytes()
zipped = 1
} else {
zpayload = payload
zipped = 0
}
if len(zpayload) > 20000 { if len(zpayload) > 10000 {
return errors.New("payload too long") return errors.New("payload too long")
} }
<<<<<<< HEAD stmt, err := db.Prepare(`UPDATE obj_job j SET j.payload = ?, j.zipped = ? WHERE j.obj_id = ?;`)
stmt, err := db.Prepare(`UPDATE obj_job j SET j.payload = ? WHERE j.obj_id = ?;`)
logOnError(err, "setJobPayload : prepare update obj_job")
=======
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") logOnError(err, "setJobTimeout : prepare update obj_job")
>>>>>>> refs/remotes/origin/master
if err != nil { if err != nil {
return err return err
} }
defer stmt.Close() defer stmt.Close()
_, err = stmt.Exec(zpayload, jobID64) _, err = stmt.Exec(zpayload, zipped, jobID64)
logOnError(err, fmt.Sprintf("setJobPayload : update obj_job(%d)", jobID64)) logOnError(err, fmt.Sprintf("setJobPayload : update obj_job(%d)", jobID64))
if err != nil { if err != nil {
return err return err