Skip to content

Commit

Permalink
Merge pull request nextcloud#10803 from nextcloud/smb-dir-instead-of-…
Browse files Browse the repository at this point in the history
…allinfo

prefer using dir instead of allinfo for getting smb file info
  • Loading branch information
MorrisJobke authored Aug 24, 2018
2 parents 48f5cbe + 4ff1d28 commit b1410df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ public function __construct($host, System $system) {
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();
}
}
Expand Down
13 changes: 13 additions & 0 deletions apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\IFileInfo;
use Icewind\SMB\INotifyHandler;
use Icewind\SMB\IServer;
use Icewind\SMB\System;
Expand Down Expand Up @@ -153,6 +154,18 @@ public function dir($path) {
* @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
Expand Down

0 comments on commit b1410df

Please sign in to comment.