Add DeleteEntry and make checksum mismatch non retryable error

This commit is contained in:
Mustafa Gezen 2023-09-06 23:28:46 +02:00
parent 41e39e07b1
commit 9ce1b9b229
Signed by: mustafa
GPG Key ID: DCDF010D946438C1

View File

@ -98,7 +98,11 @@ func (w *Worker) SetEntryIDFromRPM(entry string, uri string, checksumSha256 stri
return nil, errors.Wrap(err, "failed to hash resource")
}
if hex.EncodeToString(hash.Sum(nil)) != checksumSha256 {
return nil, errors.New("checksum does not match")
return nil, temporal.NewNonRetryableApplicationError(
"checksum does not match",
"checksumDoesNotMatch",
errors.New("client submitted a checksum that does not match the resource"),
)
}
// Read the RPM headers
@ -177,3 +181,15 @@ func (w *Worker) SetWorkerLastCheckinTime(workerID string) error {
return base.Q[mothership_db.Worker](w.db).U(wrk)
}
func (w *Worker) DeleteEntry(name string) error {
err := base.Q[mothership_db.Entry](w.db).F("name", name).Delete()
if err != nil {
if err == sql.ErrNoRows {
return nil
}
return errors.Wrap(err, "failed to delete entry")
}
return nil
}