From 7feb10b3cb74049015c73ba2f986b18db319abc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sun, 12 Jan 2020 14:39:28 +0100 Subject: [PATCH] Get mode from stat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../icewind/smb/src/Native/NativeFileInfo.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php index 9e90420d57..c1f0c90a18 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeFileInfo.php @@ -40,6 +40,8 @@ class NativeFileInfo implements IFileInfo { */ protected $modeCache; + protected $dosAttrUnavailable = false; + /** * @param NativeShare $share * @param string $path @@ -113,13 +115,17 @@ class NativeFileInfo implements IFileInfo { */ protected function getMode() { if (!$this->modeCache) { - $stat = $this->stat(); - if (isset($stat['mode'])) { - $this->modeCache = ($stat['mode']); - } else { - $attribute = $this->share->getAttribute($this->path, 'system.dos_attr.mode'); + 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;