Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teaching GNUFile methods to follow symlinks #751

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions testinfra/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,38 +223,38 @@ def get_module_class(cls, host):
class GNUFile(File):
@property
def user(self):
return self.check_output("stat -c %%U %s", self.path)
return self.check_output("stat -Lc %%U %s", self.path)

@property
def uid(self):
return int(self.check_output("stat -c %%u %s", self.path))
return int(self.check_output("stat -Lc %%u %s", self.path))

@property
def group(self):
return self.check_output("stat -c %%G %s", self.path)
return self.check_output("stat -Lc %%G %s", self.path)

@property
def gid(self):
return int(self.check_output("stat -c %%g %s", self.path))
return int(self.check_output("stat -Lc %%g %s", self.path))

@property
def mode(self):
# Supply a base of 8 when parsing an octal integer
# e.g. int('644', 8) -> 420
return int(self.check_output("stat -c %%a %s", self.path), 8)
return int(self.check_output("stat -Lc %%a %s", self.path), 8)

@property
def mtime(self):
ts = self.check_output("stat -c %%Y %s", self.path)
ts = self.check_output("stat -Lc %%Y %s", self.path)
return datetime.datetime.fromtimestamp(float(ts))

@property
def size(self):
return int(self.check_output("stat -c %%s %s", self.path))
return int(self.check_output("stat -Lc %%s %s", self.path))

@property
def inode(self):
return int(self.check_output("stat -c %%i %s", self.path))
return int(self.check_output("stat -Lc %%i %s", self.path))

@property
def md5sum(self):
Expand Down