Retry if 409 is received when uploading in a Given step
This commit is contained in:
@@ -49,6 +49,7 @@ class UploadHelper extends Assert {
|
|||||||
* @param int|null $chunkingVersion (1|2|null)
|
* @param int|null $chunkingVersion (1|2|null)
|
||||||
* if set to null chunking will not be used
|
* if set to null chunking will not be used
|
||||||
* @param int|null $noOfChunks how many chunks to upload
|
* @param int|null $noOfChunks how many chunks to upload
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return ResponseInterface
|
* @return ResponseInterface
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
@@ -63,7 +64,8 @@ class UploadHelper extends Assert {
|
|||||||
?array $headers = [],
|
?array $headers = [],
|
||||||
?int $davPathVersionToUse = 1,
|
?int $davPathVersionToUse = 1,
|
||||||
?int $chunkingVersion = null,
|
?int $chunkingVersion = null,
|
||||||
?int $noOfChunks = 1
|
?int $noOfChunks = 1,
|
||||||
|
?bool $isGivenStep = false
|
||||||
): ResponseInterface {
|
): ResponseInterface {
|
||||||
//simple upload with no chunking
|
//simple upload with no chunking
|
||||||
if ($chunkingVersion === null) {
|
if ($chunkingVersion === null) {
|
||||||
@@ -77,7 +79,16 @@ class UploadHelper extends Assert {
|
|||||||
$headers,
|
$headers,
|
||||||
$xRequestId,
|
$xRequestId,
|
||||||
$data,
|
$data,
|
||||||
$davPathVersionToUse
|
$davPathVersionToUse,
|
||||||
|
"files",
|
||||||
|
null,
|
||||||
|
"basic",
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
//prepare chunking
|
//prepare chunking
|
||||||
@@ -102,7 +113,15 @@ class UploadHelper extends Assert {
|
|||||||
$xRequestId,
|
$xRequestId,
|
||||||
null,
|
null,
|
||||||
$davPathVersionToUse,
|
$davPathVersionToUse,
|
||||||
"uploads"
|
"uploads",
|
||||||
|
null,
|
||||||
|
"basic",
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
if ($result->getStatusCode() >= 400) {
|
if ($result->getStatusCode() >= 400) {
|
||||||
return $result;
|
return $result;
|
||||||
@@ -130,7 +149,15 @@ class UploadHelper extends Assert {
|
|||||||
$xRequestId,
|
$xRequestId,
|
||||||
$chunk,
|
$chunk,
|
||||||
$davPathVersionToUse,
|
$davPathVersionToUse,
|
||||||
$davRequestType
|
$davRequestType,
|
||||||
|
null,
|
||||||
|
"basic",
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
if ($result->getStatusCode() >= 400) {
|
if ($result->getStatusCode() >= 400) {
|
||||||
return $result;
|
return $result;
|
||||||
@@ -152,7 +179,15 @@ class UploadHelper extends Assert {
|
|||||||
$xRequestId,
|
$xRequestId,
|
||||||
null,
|
null,
|
||||||
$davPathVersionToUse,
|
$davPathVersionToUse,
|
||||||
"uploads"
|
"uploads",
|
||||||
|
null,
|
||||||
|
"basic",
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
if ($result->getStatusCode() >= 400) {
|
if ($result->getStatusCode() >= 400) {
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@@ -2047,10 +2047,16 @@ trait WebDav {
|
|||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userUploadsAFileTo(string $user, string $source, string $destination):void {
|
public function userUploadsAFileTo(
|
||||||
|
string $user,
|
||||||
|
string $source,
|
||||||
|
string $destination,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$file = \fopen($this->acceptanceTestsDirLocation() . $source, 'r');
|
$file = \fopen($this->acceptanceTestsDirLocation() . $source, 'r');
|
||||||
$this->pauseUploadDelete();
|
$this->pauseUploadDelete();
|
||||||
@@ -2059,7 +2065,14 @@ trait WebDav {
|
|||||||
"PUT",
|
"PUT",
|
||||||
$destination,
|
$destination,
|
||||||
[],
|
[],
|
||||||
$file
|
$file,
|
||||||
|
"files",
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
$this->lastUploadDeleteTime = \time();
|
$this->lastUploadDeleteTime = \time();
|
||||||
$this->setResponseXml(
|
$this->setResponseXml(
|
||||||
@@ -2080,7 +2093,7 @@ trait WebDav {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userHasUploadedAFileTo(string $user, string $source, string $destination):void {
|
public function userHasUploadedAFileTo(string $user, string $source, string $destination):void {
|
||||||
$this->userUploadsAFileTo($user, $source, $destination);
|
$this->userUploadsAFileTo($user, $source, $destination, true);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user'"
|
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user'"
|
||||||
@@ -2093,11 +2106,16 @@ trait WebDav {
|
|||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function theUserUploadsAFileTo(string $source, string $destination):void {
|
public function theUserUploadsAFileTo(
|
||||||
$this->userUploadsAFileTo($this->currentUser, $source, $destination);
|
string $source,
|
||||||
|
string $destination,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
|
$this->userUploadsAFileTo($this->currentUser, $source, $destination, $isGivenStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2109,7 +2127,7 @@ trait WebDav {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function theUserHasUploadedFileTo(string $source, string $destination):void {
|
public function theUserHasUploadedFileTo(string $source, string $destination):void {
|
||||||
$this->theUserUploadsAFileTo($source, $destination);
|
$this->theUserUploadsAFileTo($source, $destination, true);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination'"
|
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination'"
|
||||||
@@ -2123,12 +2141,19 @@ trait WebDav {
|
|||||||
* @param string $server
|
* @param string $server
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userOnUploadsAFileTo(string $user, string $server, string $source, string $destination):void {
|
public function userOnUploadsAFileTo(
|
||||||
|
string $user,
|
||||||
|
string $server,
|
||||||
|
string $source,
|
||||||
|
string $destination,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
$previousServer = $this->usingServer($server);
|
$previousServer = $this->usingServer($server);
|
||||||
$this->userUploadsAFileTo($user, $source, $destination);
|
$this->userUploadsAFileTo($user, $source, $destination, $isGivenStep);
|
||||||
$this->usingServer($previousServer);
|
$this->usingServer($previousServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2143,7 +2168,7 @@ trait WebDav {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userOnHasUploadedAFileTo(string $user, string $server, string $source, string $destination):void {
|
public function userOnHasUploadedAFileTo(string $user, string $server, string $source, string $destination):void {
|
||||||
$this->userOnUploadsAFileTo($user, $server, $source, $destination);
|
$this->userOnUploadsAFileTo($user, $server, $source, $destination, true);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user' on server '$server'"
|
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user' on server '$server'"
|
||||||
@@ -2807,7 +2832,7 @@ trait WebDav {
|
|||||||
*/
|
*/
|
||||||
public function userHasUploadedFileToOfSizeBytes(string $user, string $destination, string $bytes):void {
|
public function userHasUploadedFileToOfSizeBytes(string $user, string $destination, string $bytes):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$this->userUploadsAFileToOfSizeBytes($user, $destination, $bytes);
|
$this->userUploadsAFileToOfSizeBytes($user, $destination, $bytes, true);
|
||||||
$expectedElements = new TableNode([["$destination"]]);
|
$expectedElements = new TableNode([["$destination"]]);
|
||||||
$this->checkElementList($user, $expectedElements);
|
$this->checkElementList($user, $expectedElements);
|
||||||
}
|
}
|
||||||
@@ -2818,11 +2843,23 @@ trait WebDav {
|
|||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
* @param string $bytes
|
* @param string $bytes
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userUploadsAFileToOfSizeBytes(string $user, string $destination, string $bytes):void {
|
public function userUploadsAFileToOfSizeBytes(
|
||||||
$this->userUploadsAFileToEndingWithOfSizeBytes($user, $destination, 'a', $bytes);
|
string $user,
|
||||||
|
string $destination,
|
||||||
|
string $bytes,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
|
$this->userUploadsAFileToEndingWithOfSizeBytes(
|
||||||
|
$user,
|
||||||
|
$destination,
|
||||||
|
'a',
|
||||||
|
$bytes,
|
||||||
|
$isGivenStep
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2837,7 +2874,7 @@ trait WebDav {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function userHasUploadedFileToEndingWithOfSizeBytes(string $user, string $destination, string $text, string $bytes):void {
|
public function userHasUploadedFileToEndingWithOfSizeBytes(string $user, string $destination, string $text, string $bytes):void {
|
||||||
$this->userUploadsAFileToEndingWithOfSizeBytes($user, $destination, $text, $bytes);
|
$this->userUploadsAFileToEndingWithOfSizeBytes($user, $destination, $text, $bytes, true);
|
||||||
$expectedElements = new TableNode([["$destination"]]);
|
$expectedElements = new TableNode([["$destination"]]);
|
||||||
$this->checkElementList($user, $expectedElements);
|
$this->checkElementList($user, $expectedElements);
|
||||||
}
|
}
|
||||||
@@ -2849,17 +2886,25 @@ trait WebDav {
|
|||||||
* @param string $destination
|
* @param string $destination
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param string $bytes
|
* @param string $bytes
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userUploadsAFileToEndingWithOfSizeBytes(string $user, string $destination, string $text, string $bytes):void {
|
public function userUploadsAFileToEndingWithOfSizeBytes(
|
||||||
|
string $user,
|
||||||
|
string $destination,
|
||||||
|
string $text,
|
||||||
|
string $bytes,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
$filename = "filespecificSize.txt";
|
$filename = "filespecificSize.txt";
|
||||||
$this->createLocalFileOfSpecificSize($filename, $bytes, $text);
|
$this->createLocalFileOfSpecificSize($filename, $bytes, $text);
|
||||||
Assert::assertFileExists($this->workStorageDirLocation() . $filename);
|
Assert::assertFileExists($this->workStorageDirLocation() . $filename);
|
||||||
$this->userUploadsAFileTo(
|
$this->userUploadsAFileTo(
|
||||||
$user,
|
$user,
|
||||||
$this->temporaryStorageSubfolderName() . "/$filename",
|
$this->temporaryStorageSubfolderName() . "/$filename",
|
||||||
$destination
|
$destination,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
$this->removeFile($this->workStorageDirLocation(), $filename);
|
$this->removeFile($this->workStorageDirLocation(), $filename);
|
||||||
}
|
}
|
||||||
@@ -2903,6 +2948,7 @@ trait WebDav {
|
|||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string|null $content
|
* @param string|null $content
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
@@ -2911,7 +2957,8 @@ trait WebDav {
|
|||||||
public function uploadFileWithContent(
|
public function uploadFileWithContent(
|
||||||
string $user,
|
string $user,
|
||||||
?string $content,
|
?string $content,
|
||||||
string $destination
|
string $destination,
|
||||||
|
?bool $isGivenStep = false
|
||||||
): array {
|
): array {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$this->pauseUploadDelete();
|
$this->pauseUploadDelete();
|
||||||
@@ -2920,7 +2967,14 @@ trait WebDav {
|
|||||||
"PUT",
|
"PUT",
|
||||||
$destination,
|
$destination,
|
||||||
[],
|
[],
|
||||||
$content
|
$content,
|
||||||
|
"files",
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
$this->setResponseXml(
|
$this->setResponseXml(
|
||||||
HttpRequestHelper::parseResponseAsXml($this->response)
|
HttpRequestHelper::parseResponseAsXml($this->response)
|
||||||
@@ -2956,7 +3010,7 @@ trait WebDav {
|
|||||||
?string $content,
|
?string $content,
|
||||||
string $destination
|
string $destination
|
||||||
):array {
|
):array {
|
||||||
$fileId = $this->uploadFileWithContent($this->getAdminUsername(), $content, $destination);
|
$fileId = $this->uploadFileWithContent($this->getAdminUsername(), $content, $destination, true);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
"HTTP status code was not 201 or 204 while trying to upload file '$destination'"
|
"HTTP status code was not 201 or 204 while trying to upload file '$destination'"
|
||||||
@@ -3010,12 +3064,12 @@ trait WebDav {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @When user :user uploads file :source to :destination with mtime :mtime using the WebDAV API
|
* @When user :user uploads file :source to :destination with mtime :mtime using the WebDAV API
|
||||||
* @Given user :user has uploaded file :source to :destination with mtime :mtime using the WebDAV API
|
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
* @param string $mtime Time in human-readable format is taken as input which is converted into milliseconds that is used by API
|
* @param string $mtime Time in human-readable format is taken as input which is converted into milliseconds that is used by API
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -3024,7 +3078,8 @@ trait WebDav {
|
|||||||
string $user,
|
string $user,
|
||||||
string $source,
|
string $source,
|
||||||
string $destination,
|
string $destination,
|
||||||
string $mtime
|
string $mtime,
|
||||||
|
?bool $isGivenStep = false
|
||||||
):void {
|
):void {
|
||||||
$mtime = new DateTime($mtime);
|
$mtime = new DateTime($mtime);
|
||||||
$mtime = $mtime->format('U');
|
$mtime = $mtime->format('U');
|
||||||
@@ -3037,7 +3092,36 @@ trait WebDav {
|
|||||||
$destination,
|
$destination,
|
||||||
$this->getStepLineRef(),
|
$this->getStepLineRef(),
|
||||||
["X-OC-Mtime" => $mtime],
|
["X-OC-Mtime" => $mtime],
|
||||||
$this->getDavPathVersion()
|
$this->getDavPathVersion(),
|
||||||
|
null,
|
||||||
|
1,
|
||||||
|
$isGivenStep
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given user :user has uploaded file :source to :destination with mtime :mtime using the WebDAV API
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param string $source
|
||||||
|
* @param string $destination
|
||||||
|
* @param string $mtime Time in human-readable format is taken as input which is converted into milliseconds that is used by API
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function userHasUploadedFileToWithMtimeUsingTheWebdavApi(
|
||||||
|
string $user,
|
||||||
|
string $source,
|
||||||
|
string $destination,
|
||||||
|
string $mtime
|
||||||
|
):void {
|
||||||
|
$this->userUploadsFileToWithMtimeUsingTheWebdavApi(
|
||||||
|
$user,
|
||||||
|
$source,
|
||||||
|
$destination,
|
||||||
|
$mtime,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3072,7 +3156,17 @@ trait WebDav {
|
|||||||
$filename,
|
$filename,
|
||||||
["X-OC-Mtime" => $mtime],
|
["X-OC-Mtime" => $mtime],
|
||||||
$this->getStepLineRef(),
|
$this->getStepLineRef(),
|
||||||
$content
|
$content,
|
||||||
|
WebDavHelper::DAV_VERSION_OLD,
|
||||||
|
"files",
|
||||||
|
null,
|
||||||
|
"basic",
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3157,7 +3251,7 @@ trait WebDav {
|
|||||||
string $destination
|
string $destination
|
||||||
):array {
|
):array {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$fileId = $this->uploadFileWithContent($user, $content, $destination);
|
$fileId = $this->uploadFileWithContent($user, $content, $destination, true);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
"HTTP status code was not 201 or 204 while trying to upload file '$destination' for user '$user'"
|
"HTTP status code was not 201 or 204 while trying to upload file '$destination' for user '$user'"
|
||||||
@@ -3254,6 +3348,7 @@ trait WebDav {
|
|||||||
* @param string $checksum
|
* @param string $checksum
|
||||||
* @param string|null $content
|
* @param string|null $content
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -3261,7 +3356,8 @@ trait WebDav {
|
|||||||
string $user,
|
string $user,
|
||||||
string $checksum,
|
string $checksum,
|
||||||
?string $content,
|
?string $content,
|
||||||
string $destination
|
string $destination,
|
||||||
|
?bool $isGivenStep = false
|
||||||
):void {
|
):void {
|
||||||
$this->pauseUploadDelete();
|
$this->pauseUploadDelete();
|
||||||
$this->response = $this->makeDavRequest(
|
$this->response = $this->makeDavRequest(
|
||||||
@@ -3269,7 +3365,14 @@ trait WebDav {
|
|||||||
"PUT",
|
"PUT",
|
||||||
$destination,
|
$destination,
|
||||||
['OC-Checksum' => $checksum],
|
['OC-Checksum' => $checksum],
|
||||||
$content
|
$content,
|
||||||
|
"files",
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
$this->lastUploadDeleteTime = \time();
|
$this->lastUploadDeleteTime = \time();
|
||||||
$this->pushToLastStatusCodesArrays();
|
$this->pushToLastStatusCodesArrays();
|
||||||
@@ -3295,7 +3398,8 @@ trait WebDav {
|
|||||||
$user,
|
$user,
|
||||||
$checksum,
|
$checksum,
|
||||||
$content,
|
$content,
|
||||||
$destination
|
$destination,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
@@ -3590,7 +3694,7 @@ trait WebDav {
|
|||||||
$admin,
|
$admin,
|
||||||
__METHOD__ . "The provided user is not admin but '" . $admin . "'"
|
__METHOD__ . "The provided user is not admin but '" . $admin . "'"
|
||||||
);
|
);
|
||||||
$this->userCreatesFolder($admin, $destination);
|
$this->userCreatesFolder($admin, $destination, true);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
"HTTP status code was not 201 or 204 while trying to create folder '$destination' for admin '$admin'"
|
"HTTP status code was not 201 or 204 while trying to create folder '$destination' for admin '$admin'"
|
||||||
@@ -3754,6 +3858,7 @@ trait WebDav {
|
|||||||
* @param int $total
|
* @param int $total
|
||||||
* @param string|null $data
|
* @param string|null $data
|
||||||
* @param string $destination
|
* @param string $destination
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -3762,7 +3867,8 @@ trait WebDav {
|
|||||||
int $num,
|
int $num,
|
||||||
int $total,
|
int $total,
|
||||||
?string $data,
|
?string $data,
|
||||||
string $destination
|
string $destination,
|
||||||
|
?bool $isGivenStep = false
|
||||||
):void {
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$num -= 1;
|
$num -= 1;
|
||||||
@@ -3774,7 +3880,13 @@ trait WebDav {
|
|||||||
$file,
|
$file,
|
||||||
['OC-Chunked' => '1'],
|
['OC-Chunked' => '1'],
|
||||||
$data,
|
$data,
|
||||||
"uploads"
|
"uploads",
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
$this->lastUploadDeleteTime = \time();
|
$this->lastUploadDeleteTime = \time();
|
||||||
}
|
}
|
||||||
@@ -3800,7 +3912,7 @@ trait WebDav {
|
|||||||
string $destination
|
string $destination
|
||||||
):void {
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$this->userUploadsChunkedFile($user, $num, $total, $data, $destination);
|
$this->userUploadsChunkedFile($user, $num, $total, $data, $destination, true);
|
||||||
$this->theHTTPStatusCodeShouldBe(
|
$this->theHTTPStatusCodeShouldBe(
|
||||||
["201", "204"],
|
["201", "204"],
|
||||||
"HTTP status code was not 201 or 204 while trying to upload chunk $num of $total to file '$destination' for user '$user'"
|
"HTTP status code was not 201 or 204 while trying to upload chunk $num of $total to file '$destination' for user '$user'"
|
||||||
@@ -3882,7 +3994,7 @@ trait WebDav {
|
|||||||
* | 1 | first data |
|
* | 1 | first data |
|
||||||
* | 2 | second data |
|
* | 2 | second data |
|
||||||
* Chunks may be numbered out-of-order if desired.
|
* Chunks may be numbered out-of-order if desired.
|
||||||
* @param bool $checkActions
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -3892,7 +4004,7 @@ trait WebDav {
|
|||||||
string $type,
|
string $type,
|
||||||
string $file,
|
string $file,
|
||||||
TableNode $chunkDetails,
|
TableNode $chunkDetails,
|
||||||
bool $checkActions = false
|
?bool $isGivenStep = false
|
||||||
):void {
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$async = false;
|
$async = false;
|
||||||
@@ -3906,7 +4018,7 @@ trait WebDav {
|
|||||||
'chunking-42',
|
'chunking-42',
|
||||||
$chunkDetails->getHash(),
|
$chunkDetails->getHash(),
|
||||||
$async,
|
$async,
|
||||||
$checkActions
|
$isGivenStep
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3922,7 +4034,7 @@ trait WebDav {
|
|||||||
* [content] data content of the chunk
|
* [content] data content of the chunk
|
||||||
* Chunks may be numbered out-of-order if desired.
|
* Chunks may be numbered out-of-order if desired.
|
||||||
* @param bool $async use asynchronous MOVE at the end or not
|
* @param bool $async use asynchronous MOVE at the end or not
|
||||||
* @param bool $checkActions
|
* @param bool $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -3932,10 +4044,10 @@ trait WebDav {
|
|||||||
string $chunkingId,
|
string $chunkingId,
|
||||||
array $chunkDetails,
|
array $chunkDetails,
|
||||||
bool $async = false,
|
bool $async = false,
|
||||||
bool $checkActions = false
|
bool $isGivenStep = false
|
||||||
):void {
|
):void {
|
||||||
$this->pauseUploadDelete();
|
$this->pauseUploadDelete();
|
||||||
if ($checkActions) {
|
if ($isGivenStep) {
|
||||||
$this->userHasCreatedANewChunkingUploadWithId($user, $chunkingId);
|
$this->userHasCreatedANewChunkingUploadWithId($user, $chunkingId);
|
||||||
} else {
|
} else {
|
||||||
$this->userCreatesANewChunkingUploadWithId($user, $chunkingId);
|
$this->userCreatesANewChunkingUploadWithId($user, $chunkingId);
|
||||||
@@ -3943,7 +4055,7 @@ trait WebDav {
|
|||||||
foreach ($chunkDetails as $chunkDetail) {
|
foreach ($chunkDetails as $chunkDetail) {
|
||||||
$chunkNumber = (int)$chunkDetail['number'];
|
$chunkNumber = (int)$chunkDetail['number'];
|
||||||
$chunkContent = $chunkDetail['content'];
|
$chunkContent = $chunkDetail['content'];
|
||||||
if ($checkActions) {
|
if ($isGivenStep) {
|
||||||
$this->userHasUploadedNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId);
|
$this->userHasUploadedNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId);
|
||||||
} else {
|
} else {
|
||||||
$this->userUploadsNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId);
|
$this->userUploadsNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId);
|
||||||
@@ -3953,8 +4065,8 @@ trait WebDav {
|
|||||||
if ($async === true) {
|
if ($async === true) {
|
||||||
$headers = ['OC-LazyOps' => 'true'];
|
$headers = ['OC-LazyOps' => 'true'];
|
||||||
}
|
}
|
||||||
$this->moveNewDavChunkToFinalFile($user, $chunkingId, $file, $headers);
|
$this->moveNewDavChunkToFinalFile($user, $chunkingId, $file, $headers, $isGivenStep);
|
||||||
if ($checkActions) {
|
if ($isGivenStep) {
|
||||||
$this->theHTTPStatusCodeShouldBeSuccess();
|
$this->theHTTPStatusCodeShouldBeSuccess();
|
||||||
}
|
}
|
||||||
$this->lastUploadDeleteTime = \time();
|
$this->lastUploadDeleteTime = \time();
|
||||||
@@ -3965,10 +4077,15 @@ trait WebDav {
|
|||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $id
|
* @param string $id
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userCreatesANewChunkingUploadWithId(string $user, string $id):void {
|
public function userCreatesANewChunkingUploadWithId(
|
||||||
|
string $user,
|
||||||
|
string $id,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$destination = "/uploads/$user/$id";
|
$destination = "/uploads/$user/$id";
|
||||||
$this->response = $this->makeDavRequest(
|
$this->response = $this->makeDavRequest(
|
||||||
@@ -3977,7 +4094,13 @@ trait WebDav {
|
|||||||
$destination,
|
$destination,
|
||||||
[],
|
[],
|
||||||
null,
|
null,
|
||||||
"uploads"
|
"uploads",
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3990,7 +4113,7 @@ trait WebDav {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userHasCreatedANewChunkingUploadWithId(string $user, string $id):void {
|
public function userHasCreatedANewChunkingUploadWithId(string $user, string $id):void {
|
||||||
$this->userCreatesANewChunkingUploadWithId($user, $id);
|
$this->userCreatesANewChunkingUploadWithId($user, $id, true);
|
||||||
$this->theHTTPStatusCodeShouldBeSuccess();
|
$this->theHTTPStatusCodeShouldBeSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4001,10 +4124,17 @@ trait WebDav {
|
|||||||
* @param int $num
|
* @param int $num
|
||||||
* @param string|null $data
|
* @param string|null $data
|
||||||
* @param string $id
|
* @param string $id
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userUploadsNewChunkFileOfWithToId(string $user, int $num, ?string $data, string $id):void {
|
public function userUploadsNewChunkFileOfWithToId(
|
||||||
|
string $user,
|
||||||
|
int $num,
|
||||||
|
?string $data,
|
||||||
|
string $id,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$destination = "/uploads/$user/$id/$num";
|
$destination = "/uploads/$user/$id/$num";
|
||||||
$this->response = $this->makeDavRequest(
|
$this->response = $this->makeDavRequest(
|
||||||
@@ -4013,7 +4143,13 @@ trait WebDav {
|
|||||||
$destination,
|
$destination,
|
||||||
[],
|
[],
|
||||||
$data,
|
$data,
|
||||||
"uploads"
|
"uploads",
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
$this->pushToLastStatusCodesArrays();
|
$this->pushToLastStatusCodesArrays();
|
||||||
}
|
}
|
||||||
@@ -4029,7 +4165,7 @@ trait WebDav {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userHasUploadedNewChunkFileOfWithToId(string $user, int $num, ?string $data, string $id):void {
|
public function userHasUploadedNewChunkFileOfWithToId(string $user, int $num, ?string $data, string $id):void {
|
||||||
$this->userUploadsNewChunkFileOfWithToId($user, $num, $data, $id);
|
$this->userUploadsNewChunkFileOfWithToId($user, $num, $data, $id, true);
|
||||||
$this->theHTTPStatusCodeShouldBeSuccess();
|
$this->theHTTPStatusCodeShouldBeSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4232,10 +4368,17 @@ trait WebDav {
|
|||||||
* @param string $id upload id
|
* @param string $id upload id
|
||||||
* @param string $destination destination path
|
* @param string $destination destination path
|
||||||
* @param array $headers extra headers
|
* @param array $headers extra headers
|
||||||
|
* @param bool|null $isGivenStep
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function moveNewDavChunkToFinalFile(string $user, string $id, string $destination, array $headers):void {
|
private function moveNewDavChunkToFinalFile(
|
||||||
|
string $user,
|
||||||
|
string $id,
|
||||||
|
string $destination,
|
||||||
|
array $headers,
|
||||||
|
?bool $isGivenStep = false
|
||||||
|
):void {
|
||||||
$user = $this->getActualUsername($user);
|
$user = $this->getActualUsername($user);
|
||||||
$source = "/uploads/$user/$id/.file";
|
$source = "/uploads/$user/$id/.file";
|
||||||
$headers['Destination'] = $this->destinationHeaderValue(
|
$headers['Destination'] = $this->destinationHeaderValue(
|
||||||
@@ -4249,7 +4392,13 @@ trait WebDav {
|
|||||||
$source,
|
$source,
|
||||||
$headers,
|
$headers,
|
||||||
null,
|
null,
|
||||||
"uploads"
|
"uploads",
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
null,
|
||||||
|
$isGivenStep
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user