Skip to content

Commit

Permalink
Merge pull request #28697 from owncloud/stable10-cf9b04ffdb384296fdec…
Browse files Browse the repository at this point in the history
…baa1feb27bc158d4b72a

[stable10] Don't use runInSeparateProcess
  • Loading branch information
Vincent Petry committed Aug 16, 2017
2 parents 107c665 + c763d19 commit 3434833
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
8 changes: 6 additions & 2 deletions apps/dav/lib/Connector/Sabre/File.php
Expand Up @@ -232,7 +232,7 @@ public function put($data) {
if (isset($this->request->server['HTTP_X_OC_MTIME'])) {
$mtime = $this->sanitizeMtime($this->request->server ['HTTP_X_OC_MTIME']);
if ($this->fileView->touch($this->path, $mtime)) {
header('X-OC-MTime: accepted');
$this->header('X-OC-MTime: accepted');
}
}

Expand Down Expand Up @@ -498,7 +498,7 @@ private function createFileChunked($data) {
$this->request->server ['HTTP_X_OC_MTIME']
);
if ($targetStorage->touch($targetInternalPath, $mtime)) {
header('X-OC-MTime: accepted');
$this->header('X-OC-MTime: accepted');
}
}

Expand Down Expand Up @@ -651,4 +651,8 @@ public function getChecksum($algo = null) {

return '';
}

protected function header($string) {
\header($string);
}
}
23 changes: 7 additions & 16 deletions apps/dav/tests/unit/Connector/Sabre/FileTest.php
Expand Up @@ -325,7 +325,11 @@ private function doPut($path, $viewRoot = null, \OC\AppFramework\Http\Request $r
null
);

$file = new File($view, $info, null, $request);
/** @var File | \PHPUnit_Framework_MockObject_MockObject $file */
$file = $this->getMockBuilder(File::class)
->setConstructorArgs([$view, $info, null, $request])
->setMethods(['header'])
->getMock();

// beforeMethod locks
$view->lockFile($path, ILockingProvider::LOCK_SHARED);
Expand All @@ -345,15 +349,6 @@ public function testPutSingleFile() {
$this->assertNotEmpty($this->doPut('/foo.txt'));
}

/**
* Determine if the underlying storage supports a negative mtime value
*
* @return boolean true if negative mtime is supported
*/
private function supportsNegativeMtime() {
return (getenv("PRIMARY_STORAGE_CONFIG") !== "swift");
}

public function legalMtimeProvider() {
return [
"string" => [
Expand Down Expand Up @@ -398,19 +393,17 @@ public function legalMtimeProvider() {
],
"negative int" => [
'HTTP_X_OC_MTIME' => -34,
'expected result' => ($this->supportsNegativeMtime() ? -34 : 0)
'expected result' => -34
],
"negative float" => [
'HTTP_X_OC_MTIME' => -34.43,
'expected result' => ($this->supportsNegativeMtime() ? -34 : 0)
'expected result' => -34
],
];
}

/**
* Test putting a file with string Mtime
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider legalMtimeProvider
*/
public function testPutSingleFileLegalMtime($requestMtime, $resultMtime) {
Expand All @@ -426,8 +419,6 @@ public function testPutSingleFileLegalMtime($requestMtime, $resultMtime) {

/**
* Test putting a file with string Mtime using chunking
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider legalMtimeProvider
*/
public function testChunkedPutLegalMtime($requestMtime, $resultMtime) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/Common.php
Expand Up @@ -170,7 +170,7 @@ public function getPermissions($path) {

public function filemtime($path) {
$stat = $this->stat($path);
if (isset($stat['mtime']) && $stat['mtime'] > 0) {
if (isset($stat['mtime'])) {
return $stat['mtime'];
} else {
return 0;
Expand Down

0 comments on commit 3434833

Please sign in to comment.