浏览代码

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
2f5f0af3fdb7e9ee607a0e178dbe2af6e10cccf4, which looks to have overlooked some
deliberate type-casts.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0a861e68df30a5d1e72bac99fe259149507cf354)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 年之前
父节点
当前提交
cf1e138ab1
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      pkg/directory/directory_unix.go

+ 4 - 4
pkg/directory/directory_unix.go

@@ -40,12 +40,12 @@ func Size(ctx context.Context, dir string) (size int64, err error) {
 
 
 		// Check inode to handle hard links correctly
 		// Check inode to handle hard links correctly
 		inode := fileInfo.Sys().(*syscall.Stat_t).Ino
 		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
 			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
 		size += s