Merge pull request #10804 from nextcloud/smb-dir-instead-of-allinfo-13

[13] prefer using dir instead of allinfo for getting smb file info
This commit is contained in:
Morris Jobke 2018-10-02 19:04:15 +02:00 committed by GitHub
commit bd3d991ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -138,6 +138,18 @@ class Share extends AbstractShare {
* @return \Icewind\SMB\IFileInfo
*/
public function stat($path) {
// some windows server setups don't seem to like the allinfo command
// use the dir command instead to get the file info where possible
if ($path !== "" && $path !== "/") {
$parent = dirname($path);
$dir = $this->dir($parent);
$file = array_values(array_filter($dir, function(IFileInfo $info) use ($path) {
return $info->getPath() === $path;
}));
if ($file) {
return $file[0];
}
}
$escapedPath = $this->escapePath($path);
$output = $this->execute('allinfo ' . $escapedPath);
// Windows and non Windows Fileserver may respond different

View File

@ -35,13 +35,17 @@ class TimeZoneProvider {
public function get() {
if (!$this->timeZone) {
$net = $this->system->getNetPath();
if ($net) {
// for local domain names we can assume same timezone
if ($net && strpos($this->host, '.') !== false) {
$command = sprintf('%s time zone -S %s',
$net,
escapeshellarg($this->host)
);
$this->timeZone = exec($command);
} else { // fallback to server timezone
}
if (!$this->timeZone) {
// fallback to server timezone
$this->timeZone = date_default_timezone_get();
}
}