summaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-03-13 14:35:37 +0100
committerRobin Appelman <icewind@owncloud.com>2015-03-13 14:36:34 +0100
commit3159af1983e32d99c03cfa4d3726fd513df950aa (patch)
treebd5a221aaf610f5e0e542e66cadef2b695a5308c /apps/files_external/3rdparty
parentc546f0bf46a51dc297be15aa1acbca5ed9a84de9 (diff)
downloadnextcloud-server-3159af1983e32d99c03cfa4d3726fd513df950aa.tar.gz
nextcloud-server-3159af1983e32d99c03cfa4d3726fd513df950aa.zip
Wait with getting the timezone from the smb server until we need it
Diffstat (limited to 'apps/files_external/3rdparty')
-rw-r--r--apps/files_external/3rdparty/composer.lock8
-rw-r--r--apps/files_external/3rdparty/composer/installed.json8
-rw-r--r--apps/files_external/3rdparty/icewind/smb/.gitignore1
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Parser.php12
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Share.php7
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php35
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php7
-rw-r--r--apps/files_external/3rdparty/icewind/smb/tests/Parser.php26
8 files changed, 81 insertions, 23 deletions
diff --git a/apps/files_external/3rdparty/composer.lock b/apps/files_external/3rdparty/composer.lock
index 3da75b2a900..0a7dcf89876 100644
--- a/apps/files_external/3rdparty/composer.lock
+++ b/apps/files_external/3rdparty/composer.lock
@@ -12,12 +12,12 @@
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
- "reference": "ededbfbaa3d7124ce8d4b6c119cd225fa342916d"
+ "reference": "ef4b128143b7272e97665b84862d77faabf7d36d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/SMB/zipball/ededbfbaa3d7124ce8d4b6c119cd225fa342916d",
- "reference": "ededbfbaa3d7124ce8d4b6c119cd225fa342916d",
+ "url": "https://api.github.com/repos/icewind1991/SMB/zipball/ef4b128143b7272e97665b84862d77faabf7d36d",
+ "reference": "ef4b128143b7272e97665b84862d77faabf7d36d",
"shasum": ""
},
"require": {
@@ -45,7 +45,7 @@
}
],
"description": "php wrapper for smbclient and libsmbclient-php",
- "time": "2015-02-10 16:37:37"
+ "time": "2015-03-13 12:17:14"
},
{
"name": "icewind/streams",
diff --git a/apps/files_external/3rdparty/composer/installed.json b/apps/files_external/3rdparty/composer/installed.json
index 03bad8abf36..eae04e877d2 100644
--- a/apps/files_external/3rdparty/composer/installed.json
+++ b/apps/files_external/3rdparty/composer/installed.json
@@ -48,12 +48,12 @@
"source": {
"type": "git",
"url": "https://github.com/icewind1991/SMB.git",
- "reference": "ededbfbaa3d7124ce8d4b6c119cd225fa342916d"
+ "reference": "ef4b128143b7272e97665b84862d77faabf7d36d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/icewind1991/SMB/zipball/ededbfbaa3d7124ce8d4b6c119cd225fa342916d",
- "reference": "ededbfbaa3d7124ce8d4b6c119cd225fa342916d",
+ "url": "https://api.github.com/repos/icewind1991/SMB/zipball/ef4b128143b7272e97665b84862d77faabf7d36d",
+ "reference": "ef4b128143b7272e97665b84862d77faabf7d36d",
"shasum": ""
},
"require": {
@@ -63,7 +63,7 @@
"require-dev": {
"satooshi/php-coveralls": "dev-master"
},
- "time": "2015-02-10 16:37:37",
+ "time": "2015-03-13 12:17:14",
"type": "library",
"installation-source": "source",
"autoload": {
diff --git a/apps/files_external/3rdparty/icewind/smb/.gitignore b/apps/files_external/3rdparty/icewind/smb/.gitignore
index 3ce5adbbde5..4f389129e2d 100644
--- a/apps/files_external/3rdparty/icewind/smb/.gitignore
+++ b/apps/files_external/3rdparty/icewind/smb/.gitignore
@@ -1,2 +1,3 @@
.idea
vendor
+composer.lock
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Parser.php b/apps/files_external/3rdparty/icewind/smb/src/Parser.php
index 645678d9855..381c4917a92 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Parser.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Parser.php
@@ -17,15 +17,15 @@ use Icewind\SMB\Exception\NotFoundException;
class Parser {
/**
- * @var string
+ * @var \Icewind\SMB\TimeZoneProvider
*/
- protected $timeZone;
+ protected $timeZoneProvider;
/**
- * @param string $timeZone
+ * @param \Icewind\SMB\TimeZoneProvider $timeZoneProvider
*/
- public function __construct($timeZone) {
- $this->timeZone = $timeZone;
+ public function __construct(TimeZoneProvider $timeZoneProvider) {
+ $this->timeZoneProvider = $timeZoneProvider;
}
public function checkForError($output, $path) {
@@ -120,7 +120,7 @@ class Parser {
list(, $name, $mode, $size, $time) = $matches;
if ($name !== '.' and $name !== '..') {
$mode = $this->parseMode($mode);
- $time = strtotime($time . ' ' . $this->timeZone);
+ $time = strtotime($time . ' ' . $this->timeZoneProvider->get());
$content[] = new FileInfo($basePath . '/' . $name, $name, $size, $time, $mode);
}
}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Share.php b/apps/files_external/3rdparty/icewind/smb/src/Share.php
index 5c48b1702fa..025a84380a1 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Share.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Share.php
@@ -38,8 +38,6 @@ class Share implements IShare {
*/
protected $parser;
- private $serverTimezone;
-
/**
* @param Server $server
* @param string $name
@@ -47,7 +45,7 @@ class Share implements IShare {
public function __construct($server, $name) {
$this->server = $server;
$this->name = $name;
- $this->parser = new Parser($this->server->getTimeZone());
+ $this->parser = new Parser(new TimeZoneProvider($this->server->getHost()));
}
/**
@@ -374,6 +372,9 @@ class Share implements IShare {
* @return string
*/
protected function escapePath($path) {
+ if ($path === '/') {
+ $path = '';
+ }
$path = str_replace('/', '\\', $path);
$path = str_replace('"', '^"', $path);
return '"' . $path . '"';
diff --git a/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php b/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php
new file mode 100644
index 00000000000..22406a4f956
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\SMB;
+
+class TimeZoneProvider {
+ /**
+ * @var string
+ */
+ private $host;
+
+ /**
+ * @var string
+ */
+ private $timeZone;
+
+ /**
+ * @param string $host
+ */
+ function __construct($host) {
+ $this->host = $host;
+ }
+
+ public function get() {
+ if (!$this->timeZone) {
+ $command = 'net time zone -S ' . escapeshellarg($this->host);
+ $this->timeZone = exec($command);
+ }
+ return $this->timeZone;
+ }
+}
diff --git a/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php b/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php
index 117fff1ca19..f8ccb7119ed 100644
--- a/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php
+++ b/apps/files_external/3rdparty/icewind/smb/tests/AbstractShare.php
@@ -331,7 +331,7 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
$this->share->put($this->getTextFile(), $this->root . '/foo.txt');
$dir = $this->share->dir($this->root);
$mtime = $dir[0]->getMTime();
- $this->assertTrue(abs($now - $mtime) <= 1, 'Modified time differs by ' . abs($now - $mtime) . ' seconds');
+ $this->assertTrue(abs($now - $mtime) <= 2, 'Modified time differs by ' . abs($now - $mtime) . ' seconds');
$this->share->del($this->root . '/foo.txt');
}
@@ -531,4 +531,9 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
$this->assertCount(1, $content);
$this->assertEquals($name, $content[0]->getName());
}
+
+ public function testStatRoot() {
+ $info = $this->share->stat('/');
+ $this->assertInstanceOf('\Icewind\SMB\IFileInfo', $info);
+ }
}
diff --git a/apps/files_external/3rdparty/icewind/smb/tests/Parser.php b/apps/files_external/3rdparty/icewind/smb/tests/Parser.php
index 0dd06d6af33..5caa048a664 100644
--- a/apps/files_external/3rdparty/icewind/smb/tests/Parser.php
+++ b/apps/files_external/3rdparty/icewind/smb/tests/Parser.php
@@ -25,10 +25,24 @@ class Parser extends \PHPUnit_Framework_TestCase {
}
/**
+ * @param string $timeZone
+ * @return \Icewind\SMB\TimeZoneProvider
+ */
+ private function getTimeZoneProvider($timeZone) {
+ $mock = $this->getMockBuilder('\Icewind\SMB\TimeZoneProvider')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock->expects($this->any())
+ ->method('get')
+ ->will($this->returnValue($timeZone));
+ return $mock;
+ }
+
+ /**
* @dataProvider modeProvider
*/
public function testParseMode($string, $mode) {
- $parser = new \Icewind\SMB\Parser('UTC');
+ $parser = new \Icewind\SMB\Parser($this->getTimeZoneProvider('UTC'));
$this->assertEquals($mode, $parser->parseMode($string), 'Failed parsing ' . $string);
}
@@ -48,7 +62,8 @@ class Parser extends \PHPUnit_Framework_TestCase {
'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'),
'mode' => FileInfo::MODE_NORMAL,
'size' => 29634
- ))
+ )
+ )
);
}
@@ -56,7 +71,7 @@ class Parser extends \PHPUnit_Framework_TestCase {
* @dataProvider statProvider
*/
public function testStat($output, $stat) {
- $parser = new \Icewind\SMB\Parser('UTC');
+ $parser = new \Icewind\SMB\Parser($this->getTimeZoneProvider('UTC'));
$this->assertEquals($stat, $parser->parseStat($output));
}
@@ -71,7 +86,8 @@ class Parser extends \PHPUnit_Framework_TestCase {
' 62536 blocks of size 8388608. 57113 blocks available'
),
array(
- new FileInfo('/c.pdf', 'c.pdf', 29634, strtotime('12 Oct 2013 19:05:58 CEST'), FileInfo::MODE_NORMAL)
+ new FileInfo('/c.pdf', 'c.pdf', 29634, strtotime('12 Oct 2013 19:05:58 CEST'),
+ FileInfo::MODE_NORMAL)
)
)
);
@@ -81,7 +97,7 @@ class Parser extends \PHPUnit_Framework_TestCase {
* @dataProvider dirProvider
*/
public function testDir($output, $dir) {
- $parser = new \Icewind\SMB\Parser('CEST');
+ $parser = new \Icewind\SMB\Parser($this->getTimeZoneProvider('CEST'));
$this->assertEquals($dir, $parser->parseDir($output, ''));
}
}