pkg/directory: Size(): add back type-casts to account for platform differences

I noticed the comment above this code, but didn't see a corresponding type-cast.
Looking at this file's history, I found that these were removed as part of
2f5f0af3fd, which looks to have overlooked some
deliberate type-casts.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0a861e68df)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-10-05 10:47:28 +02:00
parent afdc9a804a
commit cf1e138ab1
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -40,12 +40,12 @@ func Size(ctx context.Context, dir string) (size int64, err error) {
// Check inode to handle hard links correctly
inode := fileInfo.Sys().(*syscall.Stat_t).Ino
// inode is not a uint64 on all platforms. Cast it to avoid issues.
if _, exists := data[inode]; exists {
//nolint:unconvert // inode is not an uint64 on all platforms.
if _, exists := data[uint64(inode)]; exists {
return nil
}
// inode is not a uint64 on all platforms. Cast it to avoid issues.
data[inode] = struct{}{}
data[uint64(inode)] = struct{}{} //nolint:unconvert // inode is not an uint64 on all platforms.
size += s