/** @var \OC\Files\Storage\Storage $sourceStorage */
[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
+ $connection = \OC::$server->getDatabaseConnection();
+ $connection->beginTransaction();
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
try {
} else {
$sourceStorage->unlink($sourceInternalPath);
}
+ $connection->rollBack();
return false;
}
+ $connection->commit();
+
if ($moveSuccessful) {
$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
$result = $query->execute(array($filename, $timestamp, $location, $owner));
$this->assertEquals('/foo.txt', $folderView->getPath($id2));
}
-
+
public function testGetPathNotExisting() {
$this->expectException(\OCP\Files\NotFoundException::class);
->setMethods(['fopen'])
->getMock();
- $storage2->expects($this->any())
- ->method('fopen')
- ->will($this->returnCallback(function ($path, $mode) use ($storage2) {
- /** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Files\Storage\Temporary $storage2 */
- $source = fopen($storage2->getSourcePath($path), $mode);
- return Quota::wrap($source, 9);
- }));
+ $storage2->method('writeStream')
+ ->willReturn(0);
$storage1->mkdir('sub');
$storage1->file_put_contents('foo.txt', '0123456789ABCDEFGH');
$this->assertNull($view->getRelativePath(null));
}
-
+
public function testNullAsRoot() {
$this->expectException(\InvalidArgumentException::class);