libpod/events: use filepath.Dir for consistency in truncate()

The truncate() function in libpod/events/logfile.go used path.Dir on a filesystem path (filePath). The file is Linux/FreeBSD only per its build tag, so this isn't about Windows correctness — it's about internal consistency: the same file already calls filepath.Dir at line 32 for the same kind of path handling, and filepath is idiomatic for filesystem operations.

Also removes the now-unused 'path' import.

Fixes part of #25165

Signed-off-by: Shreya Vidyadhar <shrevidh03@gmail.com>
This commit is contained in:
Shreya Vidyadhar 2026-08-08 23:46:25 +05:30
parent 55c2d1c490
commit f03c385dcd

View file

@ -9,7 +9,6 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"time"
@ -287,7 +286,7 @@ func truncate(filePath string) error {
size := origFinfo.Size()
threshold := size / 2
tmp, err := os.CreateTemp(path.Dir(filePath), "")
tmp, err := os.CreateTemp(filepath.Dir(filePath), "")
if err != nil {
// Retry in /tmp in case creating a tmp file in the same
// directory has failed.