mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-22 13:01:33 +02:00
Make RetryingDbFunction more lenient so that it always ignores UNIQUE constraint errors, since if a DB.Create returns a UNIQUE error, then the create is not actually necessary
This commit is contained in:
parent
f1e2b8ddbf
commit
763c8208f7
@ -148,7 +148,7 @@ func buildTableRow(ctx context.Context, columnNames []string, entry data.History
|
||||
case "Timestamp":
|
||||
row = append(row, entry.StartTime.Local().Format(hctx.GetConf(ctx).TimestampFormat))
|
||||
case "Runtime":
|
||||
if entry.EndTime == time.Unix(0, 0) {
|
||||
if entry.EndTime.UnixMilli() == 0 {
|
||||
// An EndTime of zero means this is a pre-saved entry that never finished
|
||||
row = append(row, "N/A")
|
||||
} else {
|
||||
@ -718,12 +718,8 @@ func RetryingDbFunction(dbFunc func() error) error {
|
||||
time.Sleep(time.Duration(i*rand.Intn(100)) * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
if strings.Contains(errMsg, "UNIQUE constraint failed") {
|
||||
if i == 0 {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
if strings.Contains(errMsg, "UNIQUE constraint failed: history_entries.") {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unrecoverable sqlite error: %w", err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user