Skip to content

Commit bff20ed

Browse files
authored
Merge pull request #126 from open-uem/fix-93
fix: dnf history time parsing
2 parents fe0153c + 6eaf031 commit bff20ed

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

internal/commands/report/system_update_linux.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func checkDnfLastTimePackagesInstalled() time.Time {
157157
lastInstall := `dnf history list | grep -m 1 update | awk '{print $5,$6}'`
158158
out, err := exec.Command("bash", "-c", lastInstall).Output()
159159
if err != nil {
160-
log.Printf("[ERROR]: could not read APT history log, reason: %v", err)
160+
log.Printf("[ERROR]: could not read DNF history log, reason: %v", err)
161161
return time.Time{}
162162
}
163163

@@ -166,14 +166,17 @@ func checkDnfLastTimePackagesInstalled() time.Time {
166166
lastInstall := `dnf history list | grep -m 1 update | awk '{print $6,$7}'`
167167
out, err := exec.Command("bash", "-c", lastInstall).Output()
168168
if err != nil {
169-
log.Printf("[ERROR]: could not read APT history log, reason: %v", err)
169+
log.Printf("[ERROR]: could not read DNF history log, reason: %v", err)
170170
return time.Time{}
171171
}
172172

173173
t, err = time.Parse("2006-01-02 15:04", strings.TrimSpace(string(out)))
174174
if err != nil {
175-
log.Printf("[ERROR]: could not parse time string %s from DNF history log, reason: %v", string(out), err)
176-
return time.Time{}
175+
t, err = time.Parse("2006-01-02 15:04:05", strings.TrimSpace(string(out)))
176+
if err != nil {
177+
log.Printf("[ERROR]: could not parse time string %s from DNF history log, reason: %v", string(out), err)
178+
return time.Time{}
179+
}
177180
}
178181
}
179182

0 commit comments

Comments
 (0)