Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -1674,9 +1674,11 @@ public function userUploadsAFileTo($user, $source, $destination) {
'r'
)
);
$this->pauseUpload();
$this->response = $this->makeDavRequest(
$user, "PUT", $destination, [], $file
);
$this->lastUploadTime = \time();
$this->parseResponseIntoXml();
}

Expand Down Expand Up @@ -1751,6 +1753,7 @@ public function userUploadsAFileToWithChunks(
}
try {
$this->responseXml = [];
$this->pauseUpload();
$this->response = UploadHelper::upload(
$this->getBaseUrl(),
$this->getActualUsername($user),
Expand All @@ -1762,6 +1765,7 @@ public function userUploadsAFileToWithChunks(
$this->chunkingToUse,
$noOfChunks
);
$this->lastUploadTime = \time();
} catch (BadResponseException $e) {
// 4xx and 5xx responses cause an exception
$this->response = $e->getResponse();
Expand Down Expand Up @@ -2082,12 +2086,7 @@ public function userUploadsAFileWithContentTo(
$user, $content, $destination
) {
$file = \GuzzleHttp\Stream\Stream::factory($content);
$time = \time();
if ($this->lastUploadTime !== null && $time - $this->lastUploadTime < 1) {
// prevent creating two uploads with the same "stime" which is
// based on seconds, this prevents creation of uploads with same etag
\sleep(1);
}
$this->pauseUpload();
$this->response = $this->makeDavRequest(
$user, "PUT", $destination, [], $file
);
Expand All @@ -2110,13 +2109,15 @@ public function userUploadsAFileWithChecksumAndContentTo(
$user, $checksum, $content, $destination
) {
$file = \GuzzleHttp\Stream\Stream::factory($content);
$this->pauseUpload();
$this->response = $this->makeDavRequest(
$user,
"PUT",
$destination,
['OC-Checksum' => $checksum],
$file
);
$this->lastUploadTime = \time();
}

/**
Expand Down Expand Up @@ -2294,9 +2295,11 @@ public function userUploadsChunkedFile(
$num -= 1;
$data = \GuzzleHttp\Stream\Stream::factory($data);
$file = "$destination-chunking-42-$total-$num";
$this->pauseUpload();
$this->response = $this->makeDavRequest(
$user, 'PUT', $file, ['OC-Chunked' => '1'], $data, "uploads"
);
$this->lastUploadTime = \time();
}

/**
Expand Down Expand Up @@ -2346,6 +2349,7 @@ public function userUploadsTheFollowingChunksUsingNewChunking(
public function userUploadsChunksUsingNewChunking(
$user, $file, $chunkingId, $chunkDetails, $async = false
) {
$this->pauseUpload();
$this->userCreatesANewChunkingUploadWithId($user, $chunkingId);
foreach ($chunkDetails as $chunkDetail) {
$chunkNumber = $chunkDetail[0];
Expand All @@ -2357,6 +2361,7 @@ public function userUploadsChunksUsingNewChunking(
$headers = ['OC-LazyOps' => 'true'];
}
$this->moveNewDavChunkToFinalFile($user, $chunkingId, $file, $headers);
$this->lastUploadTime = \time();
}

/**
Expand Down Expand Up @@ -3097,6 +3102,19 @@ public function findEntryFromPropfindResponse($user, $entryNameToSearch = null)
return false;
}

/**
* prevent creating two uploads with the same "stime" which is
* based on seconds, this prevents creation of uploads with same etag
*
* @return void
*/
public function pauseUpload() {
$time = \time();
if ($this->lastUploadTime !== null && $time - $this->lastUploadTime < 1) {
\sleep(1);
}
}

/**
* reset settings if they were set in the scenario
*
Expand Down