Skip to content

Commit

Permalink
Исправлена ошибка index out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
audetv committed Apr 9, 2024
1 parent ddd196a commit 63e47f7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions internal/workerpool/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,14 @@ func process(workerID int, task *Task) {

splitEntries := task.Splitter.SplitEntry(context.Background(), *e)

// всего фрагментов
count := len(splitEntries)

for n, splitEntry := range splitEntries {
// Обязательно присваиваем created дату из БД, иначе будет перезаписан 0
splitEntry.Created = dbe[0].Created

timeNow := time.Unix(time.Now().Unix(), 0)
splitEntry.UpdatedAt = &timeNow

if n+1 < count {
// пока n меньше, чем всего фрагментов в БД, обновляем, иначе создаем новые
if n < len(dbe) {
splitEntry.ID = dbe[n].ID
err = updateOldEntry(&splitEntry, store.Storage, *logger)
if err != nil {
Expand Down

0 comments on commit 63e47f7

Please sign in to comment.