Compare commits

...

2 Commits

Author SHA1 Message Date
Julius Härtl 7feb10b3cb
Get mode from stat
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2020-01-12 14:39:28 +01:00
Julius Härtl 0ed473f52f
Use stat result for fetching the mode first
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2020-01-08 11:54:14 +01:00
1 changed files with 14 additions and 3 deletions

View File

@ -40,6 +40,8 @@ class NativeFileInfo implements IFileInfo {
*/
protected $modeCache;
protected $dosAttrUnavailable = false;
/**
* @param NativeShare $share
* @param string $path
@ -113,9 +115,18 @@ class NativeFileInfo implements IFileInfo {
*/
protected function getMode() {
if (!$this->modeCache) {
$attribute = $this->share->getAttribute($this->path, 'system.dos_attr.mode');
// parse hex string
$this->modeCache = (int)hexdec(substr($attribute, 2));
try {
$attribute = $this->share->getAttribute($this->path, 'system.dos_attr.modea');
// parse hex string
$this->modeCache = (int)hexdec(substr($attribute, 2));
} catch (\Exception $e) {
// getxattr should actually just return false here, so not sure why we are getting an error 104 from smbclient_state_errno
$this->dosAttrUnavailable = true;
$this->modeCache = ($this->stat()['mode'] & 0040000) ? IFileInfo::MODE_DIRECTORY : 0;
if (!($this->stat()['mode'] & 0200)) {
$this->modeCache ^= IFileInfo::MODE_READONLY;
}
}
}
return $this->modeCache;
}