Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #355 from intelzhongjie/master
Browse files Browse the repository at this point in the history
Resolve symlink issue.
  • Loading branch information
nkubala authored Apr 20, 2021
2 parents e191f5b + 006b6be commit 15751cb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions pkg/util/fs_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type DirectoryEntry struct {
}

func GetSize(path string) int64 {
stat, err := os.Stat(path)
stat, err := os.Lstat(path)
if err != nil {
logrus.Errorf("Could not obtain size for %s: %s", path, err)
return -1
Expand All @@ -56,7 +56,7 @@ func GetSize(path string) int64 {

//GetFileContents returns the contents of a file at the specified path
func GetFileContents(path string) (*string, error) {
if _, err := os.Stat(path); os.IsNotExist(err) {
if _, err := os.Lstat(path); os.IsNotExist(err) {
return nil, err
}

Expand Down Expand Up @@ -145,11 +145,11 @@ func CheckSameSymlink(f1name, f2name string) (bool, error) {

func CheckSameFile(f1name, f2name string) (bool, error) {
// Check first if files differ in size and immediately return
f1stat, err := os.Stat(f1name)
f1stat, err := os.Lstat(f1name)
if err != nil {
return false, err
}
f2stat, err := os.Stat(f2name)
f2stat, err := os.Lstat(f2name)
if err != nil {
return false, err
}
Expand Down
76 changes: 38 additions & 38 deletions tests/file_diff_expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
{
"Name": "/usr/bin/cc",
"Size": 768648
"Size": 3
},
{
"Name": "/usr/bin/cpp",
Expand Down Expand Up @@ -5043,7 +5043,7 @@
},
{
"Name": "/usr/lib/cpp",
"Size": 772720
"Size": 10
},
{
"Name": "/usr/lib/gcc",
Expand Down Expand Up @@ -5099,7 +5099,7 @@
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libasan.a",
"Size": -1
"Size": 42
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libasan.so",
Expand All @@ -5111,7 +5111,7 @@
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libatomic.a",
"Size": -1
"Size": 44
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libatomic.so",
Expand All @@ -5127,7 +5127,7 @@
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgcc_s.so",
"Size": -1
"Size": 18
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgcov.a",
Expand All @@ -5139,35 +5139,35 @@
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libgomp.so",
"Size": -1
"Size": 28
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libitm.a",
"Size": -1
"Size": 41
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libitm.so",
"Size": 35
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libmudflap.a",
"Size": -1
"Size": 45
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libmudflap.so",
"Size": 39
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libmudflapth.a",
"Size": -1
"Size": 47
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libmudflapth.so",
"Size": 41
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libquadmath.a",
"Size": -1
"Size": 46
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libquadmath.so",
Expand Down Expand Up @@ -5451,7 +5451,7 @@
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgcc_s.so",
"Size": -1
"Size": 20
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgcov.a",
Expand All @@ -5463,7 +5463,7 @@
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgomp.so",
"Size": 154880
"Size": 34
},
{
"Name": "/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libgomp.spec",
Expand Down Expand Up @@ -5511,19 +5511,19 @@
},
{
"Name": "/usr/lib64/libBrokenLocale.so",
"Size": 8480
"Size": 32
},
{
"Name": "/usr/lib64/libanl.so",
"Size": 19840
"Size": 23
},
{
"Name": "/usr/lib64/libbsd-compat.a",
"Size": 1330
},
{
"Name": "/usr/lib64/libbsd.a",
"Size": 1330
"Size": 15
},
{
"Name": "/usr/lib64/libc.so",
Expand All @@ -5535,23 +5535,23 @@
},
{
"Name": "/usr/lib64/libcidn.so",
"Size": 201064
"Size": 24
},
{
"Name": "/usr/lib64/libcrypt.so",
"Size": 40664
"Size": 25
},
{
"Name": "/usr/lib64/libdl.so",
"Size": 19288
"Size": 22
},
{
"Name": "/usr/lib64/libg.a",
"Size": 1330
},
{
"Name": "/usr/lib64/libgomp.so.1",
"Size": 154880
"Size": 16
},
{
"Name": "/usr/lib64/libgomp.so.1.0.0",
Expand All @@ -5563,59 +5563,59 @@
},
{
"Name": "/usr/lib64/libm.so",
"Size": 1137024
"Size": 21
},
{
"Name": "/usr/lib64/libmcheck.a",
"Size": 11440
},
{
"Name": "/usr/lib64/libmpc.so.3",
"Size": 99664
"Size": 15
},
{
"Name": "/usr/lib64/libmpc.so.3.0.0",
"Size": 99664
},
{
"Name": "/usr/lib64/libmpfr.so.4",
"Size": 377424
"Size": 16
},
{
"Name": "/usr/lib64/libmpfr.so.4.1.1",
"Size": 377424
},
{
"Name": "/usr/lib64/libnsl.so",
"Size": 115848
"Size": 23
},
{
"Name": "/usr/lib64/libnss_compat.so",
"Size": 46432
"Size": 30
},
{
"Name": "/usr/lib64/libnss_db.so",
"Size": 38088
"Size": 26
},
{
"Name": "/usr/lib64/libnss_dns.so",
"Size": 31408
"Size": 27
},
{
"Name": "/usr/lib64/libnss_files.so",
"Size": 61624
"Size": 29
},
{
"Name": "/usr/lib64/libnss_hesiod.so",
"Size": 23680
"Size": 30
},
{
"Name": "/usr/lib64/libnss_nis.so",
"Size": 56656
"Size": 27
},
{
"Name": "/usr/lib64/libnss_nisplus.so",
"Size": 69680
"Size": 31
},
{
"Name": "/usr/lib64/libpthread.so",
Expand All @@ -5627,23 +5627,23 @@
},
{
"Name": "/usr/lib64/libresolv.so",
"Size": 105824
"Size": 26
},
{
"Name": "/usr/lib64/librpcsvc.a",
"Size": 54398
},
{
"Name": "/usr/lib64/librt.so",
"Size": 43776
"Size": 22
},
{
"Name": "/usr/lib64/libthread_db.so",
"Size": 38232
"Size": 29
},
{
"Name": "/usr/lib64/libutil.so",
"Size": 14496
"Size": 24
},
{
"Name": "/usr/libexec/gcc",
Expand All @@ -5667,11 +5667,11 @@
},
{
"Name": "/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/liblto_plugin.so",
"Size": 76584
"Size": 22
},
{
"Name": "/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/liblto_plugin.so.0",
"Size": 76584
"Size": 22
},
{
"Name": "/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/liblto_plugin.so.0.0.0",
Expand All @@ -5691,7 +5691,7 @@
},
{
"Name": "/usr/libexec/getconf/default",
"Size": 26544
"Size": 19
},
{
"Name": "/usr/share/doc/gcc-4.8.5",
Expand Down Expand Up @@ -6803,4 +6803,4 @@
]
}
}
]
]

0 comments on commit 15751cb

Please sign in to comment.