Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,8 @@ protected function sanitizeMtime ($mtimeFromRequest) {
return $mtime;
}

public function getView() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should expose this. Taking into account that we only need one method of the view, we can wrap that method we need inside a specific method in the node. This way we don't need to expose the underlying view object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean creating a method putDirectly($path, $data) and call that from outside ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's what I mean,

return $this->fileView;
}

}
4 changes: 2 additions & 2 deletions apps/dav/lib/Upload/UploadFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function __construct(Directory $node) {
}

function createFile($name, $data = null) {
// TODO: verify name - should be a simple number
$this->node->createFile($name, $data);
$view = $this->node->getView();
$view->file_put_contents($this->node->getPath() . '/' . $name, $data);
}

function createDirectory($name) {
Expand Down
59 changes: 23 additions & 36 deletions tests/integration/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,55 +859,42 @@ public function userUploadsNewChunkFileOfWithToId($user, $num, $data, $id)
}

/**
* @Given user :user uploads new chunk file :num with :data to id :id with checksum :checksum
* @Given user :user moves new chunk file with id :id to :dest
*/
public function userUploadsNewChunkFileOfWithToIdWithChecksum($user, $num, $data, $id, $checksum)
{
try {
$data = \GuzzleHttp\Stream\Stream::factory($data);
$destination = '/uploads/' . $user . '/' . $id . '/' . $num;
$this->makeDavRequest(
$user,
'PUT',
$destination,
['OC-Checksum' => $checksum],
$data,
"uploads"
);
} catch (\GuzzleHttp\Exception\BadResponseException $ex) {
$this->response = $ex->getResponse();
}
public function userMovesNewChunkFileWithIdToMychunkedfile($user, $id, $dest) {
$this->moveNewDavChunkToFinalFile($user, $id, $dest, []);
}

/**
* @Given user :user moves new chunk file with id :id to :dest
* @Then user :user moves new chunk file with id :id to :dest with size :size
*/
public function userMovesNewChunkFileWithIdToMychunkedfile($user, $id, $dest)
{
try {
$source = '/uploads/' . $user . '/' . $id . '/.file';
$destination = $this->baseUrlWithoutOCSAppendix() . $this->getDavFilesPath($user) . $dest;
$this->makeDavRequest($user, 'MOVE', $source, [
'Destination' => $destination
], null, "uploads");
} catch (\GuzzleHttp\Exception\RequestException $ex) {
$this->response = $ex->getResponse();
}
public function userMovesNewChunkFileWithIdToMychunkedfileWithSize($user, $id, $dest, $size) {
$this->moveNewDavChunkToFinalFile($user, $id, $dest, ['OC-Total-Length' => $size]);
}

/**
* @Then user :user moves new chunk file with id :id to :dest with size :size
* @Then user :user moves new chunk file with id :id to :dest with checksum :checksum
*/
public function userMovesNewChunkFileWithIdToMychunkedfileWithSize($user, $id, $dest, $size)
{
public function userMovesNewChunkFileWithIdToMychunkedfileWithChecksum($user, $id, $dest, $checksum) {
$this->moveNewDavChunkToFinalFile($user, $id, $dest, ['OC-Checksum' => $checksum]);
}

/**
* Move chunked new dav file to final file
*
* @param string $user user
* @param string $id upload id
* @param string $dest destination path
* @param array $headers extra headers
*/
private function moveNewDavChunkToFinalFile($user, $id, $dest, $headers) {
$source = '/uploads/' . $user . '/' . $id . '/.file';
$destination = $this->baseUrlWithoutOCSAppendix() . $this->getDavFilesPath($user) . $dest;

$headers['Destination'] = $destination;

try {
$this->response = $this->makeDavRequest($user, 'MOVE', $source, [
'Destination' => $destination,
'OC-Total-Length' => $size
], null, "uploads");
$this->response = $this->makeDavRequest($user, 'MOVE', $source, $headers, null, "uploads");
} catch(\GuzzleHttp\Exception\BadResponseException $ex) {
$this->response = $ex->getResponse();
}
Expand Down
14 changes: 12 additions & 2 deletions tests/integration/features/checksums.feature
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,22 @@ Feature: checksums
When user "user0" downloads the file "/local_storage/prueba_cksum.txt"
Then The header checksum should match "SHA1:a35b7605c8f586d735435535c337adc066c2ccb6"

Scenario: Upload chunked file where checksum does not match
Scenario: Upload new dav chunked file where checksum matches
Given using new dav path
And user "user0" exists
And user "user0" creates a new chunking upload with id "chunking-42"
And user "user0" uploads new chunk file "2" with "BBBBB" to id "chunking-42"
And user "user0" uploads new chunk file "3" with "CCCCC" to id "chunking-42" with checksum "SHA1:f005ba11"
And user "user0" uploads new chunk file "3" with "CCCCC" to id "chunking-42"
And user "user0" moves new chunk file with id "chunking-42" to "/myChunkedFile.txt" with checksum "SHA1:5d84d61b03fdacf813640f5242d309721e0629b1"
Then the HTTP status code should be "201"

Scenario: Upload new dav chunked file where checksum does not match
Given using new dav path
And user "user0" exists
And user "user0" creates a new chunking upload with id "chunking-42"
And user "user0" uploads new chunk file "2" with "BBBBB" to id "chunking-42"
And user "user0" uploads new chunk file "3" with "CCCCC" to id "chunking-42"
And user "user0" moves new chunk file with id "chunking-42" to "/myChunkedFile.txt" with checksum "SHA1:f005ba11"
Then the HTTP status code should be "400"

Scenario: Upload a file where checksum does not match
Expand Down