fix share api tests

remotes/origin/ldap_group_count
Bjoern Schiessle 11 years ago
parent 27c5a978f9
commit ed981294f1
  1. 12
      apps/files_sharing/lib/api.php
  2. 21
      apps/files_sharing/lib/cache.php
  3. 2
      apps/files_sharing/lib/share/file.php
  4. 39
      apps/files_sharing/lib/sharedstorage.php
  5. 2
      apps/files_sharing/lib/watcher.php
  6. 70
      apps/files_sharing/tests/api.php
  7. 12
      apps/files_sharing/tests/base.php
  8. 60
      apps/files_sharing/tests/cache.php
  9. 15
      apps/files_sharing/tests/permissions.php
  10. 33
      apps/files_sharing/tests/watcher.php
  11. 6
      lib/private/share/share.php

@ -184,7 +184,6 @@ class Api {
$receivedFrom = \OCP\Share::getItemSharedWithBySource($itemType, $file['fileid']);
reset($share);
$key = key($share);
$share[$key]['path'] = self::correctPath($share[$key]['path'], $path);
if ($receivedFrom) {
$share[$key]['received_from'] = $receivedFrom['uid_owner'];
$share[$key]['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
@ -531,15 +530,4 @@ class Api {
}
/**
* @brief make sure that the path has the correct root
*
* @param string $path path returned from the share API
* @param string $folder current root folder
* @return string the correct path
*/
protected static function correctPath($path, $folder) {
return \OC_Filesystem::normalizePath('/' . $folder . '/' . basename($path));
}
}

@ -47,7 +47,7 @@ class Shared_Cache extends Cache {
* @return \OC\Files\Cache\Cache
*/
private function getSourceCache($target) {
if ($target === false) {
if ($target === false || $target === $this->storage->getMountPoint()) {
$target = '';
}
$source = \OC_Share_Backend_File::getSource($target, $this->storage->getMountPoint(), $this->storage->getShareType());
@ -86,8 +86,11 @@ class Shared_Cache extends Cache {
public function get($file) {
if (is_string($file)) {
if ($cache = $this->getSourceCache($file)) {
$path = 'files/' . $this->storage->getMountPoint();
$path .= ($file !== '') ? '/' . $file : '';
$data = $cache->get($this->files[$file]);
$data['displayname_owner'] = \OC_User::getDisplayName($this->storage->getSharedFrom());
$data['path'] = $path;
return $data;
}
} else {
@ -99,7 +102,7 @@ class Shared_Cache extends Cache {
}
$query = \OC_DB::prepare(
'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`,'
. ' `size`, `mtime`, `encrypted`, `unencrypted_size`'
. ' `size`, `mtime`, `encrypted`, `unencrypted_size`, `storage_mtime`'
. ' FROM `*PREFIX*filecache` WHERE `fileid` = ?');
$result = $query->execute(array($file));
$data = $result->fetchRow();
@ -138,12 +141,15 @@ class Shared_Cache extends Cache {
$folder = '';
}
$dir = 'files/' . $this->storage->getMountPoint();
$dir .= ($folder !== '') ? '/' . $folder : '';
$cache = $this->getSourceCache($folder);
if ($cache) {
$parent = $this->storage->getFile($folder);
$sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
foreach ($sourceFolderContent as $key => $c) {
$sourceFolderContent[$key]['usersPath'] = 'files/' . $folder . '/' . $c['name'];
$sourceFolderContent[$key]['path'] = $dir . '/' . $c['name'];
$sourceFolderContent[$key]['uid_owner'] = $parent['uid_owner'];
$sourceFolderContent[$key]['displayname_owner'] = $parent['uid_owner'];
}
@ -178,7 +184,11 @@ class Shared_Cache extends Cache {
* @return int
*/
public function getId($file) {
if ($cache = $this->getSourceCache($file)) {
if ($file === false) {
return $this->storage->getSourceId();
}
$cache = $this->getSourceCache($file);
if ($cache) {
return $cache->getId($this->files[$file]);
}
return -1;
@ -292,9 +302,6 @@ class Shared_Cache extends Cache {
if ($file['mimetype'] === 'httpd/unix-directory') {
$exploreDirs[] = ltrim($dir . '/' . $file['name'], '/');
} else if (($mimepart && $file['mimepart'] === $mimepart) || ($mimetype && $file['mimetype'] === $mimetype)) {
// usersPath not reliable
//$file['path'] = $file['usersPath'];
$file['path'] = ltrim($dir . '/' . $file['name'], '/');
$result[] = $file;
}
}

@ -87,7 +87,7 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
'path' => $items[key($items)]['path'],
'storage' => $items[key($items)]['storage'],
'permissions' => $items[key($items)]['permissions'],
'uid_owner' => $items[key($items)]['uid_owner']
'uid_owner' => $items[key($items)]['uid_owner'],
);
} else if ($format == self::FORMAT_GET_FOLDER_CONTENTS) {
$files = array();

@ -138,15 +138,9 @@ class Shared extends \OC\Files\Storage\Common {
}
public function opendir($path) {
if ($path == '' || $path == '/') {
$files = \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_Folder::FORMAT_OPENDIR);
\OC\Files\Stream\Dir::register($this->mountPoint, $files);
return opendir('fakedir://' . $this->mountPoint);
} else if ($source = $this->getSourcePath($path)) {
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
return $storage->opendir($internalPath);
}
return false;
$source = $this->getSourcePath($path);
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
return $storage->opendir($internalPath);
}
public function is_dir($path) {
@ -242,25 +236,9 @@ class Shared extends \OC\Files\Storage\Common {
}
public function filemtime($path) {
if ($path == '' || $path == '/') {
$mtime = 0;
$dh = $this->opendir($path);
if (is_resource($dh)) {
while (($filename = readdir($dh)) !== false) {
$tempmtime = $this->filemtime($filename);
if ($tempmtime > $mtime) {
$mtime = $tempmtime;
}
}
}
return $mtime;
} else {
$source = $this->getSourcePath($path);
if ($source) {
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
return $storage->filemtime($internalPath);
}
}
$source = $this->getSourcePath($path);
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
return $storage->filemtime($internalPath);
}
public function file_get_contents($path) {
@ -285,7 +263,7 @@ class Shared extends \OC\Files\Storage\Common {
return false;
}
$info = array(
'target' => $this->mountPoint . $path,
'target' => $this->mountPoint . '/' . $path,
'source' => $source,
);
\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
@ -532,9 +510,6 @@ class Shared extends \OC\Files\Storage\Common {
}
public function hasUpdated($path, $time) {
if ($path == '') {
return false;
}
return $this->filemtime($path) > $time;
}

@ -32,7 +32,7 @@ class Shared_Watcher extends Watcher {
* @param string $path
*/
public function checkUpdate($path) {
if ($path != '' && parent::checkUpdate($path) === true) {
if (parent::checkUpdate($path) === true) {
// since checkUpdate() has already updated the size of the subdirs,
// only apply the update to the owner's parent dirs

@ -324,10 +324,10 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
$this->assertTrue(is_string($result));
$testValues=array(
array('query' => 'Shared/' . $this->folder,
'expectedResult' => '/Shared' . $this->folder . $this->filename),
array('query' => 'Shared/' . $this->folder . $this->subfolder,
'expectedResult' => '/Shared' . $this->folder . $this->subfolder . $this->filename),
array('query' => $this->folder,
'expectedResult' => $this->folder . $this->filename),
array('query' => $this->folder . $this->subfolder,
'expectedResult' => $this->folder . $this->subfolder . $this->filename),
);
foreach ($testValues as $value) {
@ -382,7 +382,7 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
// share was successful?
$this->assertTrue(is_string($result));
$_GET['path'] = '/Shared';
$_GET['path'] = '/';
$_GET['subfiles'] = 'true';
$result = Share\Api::getAllShares(array());
@ -395,7 +395,7 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
// we should get exactly one result
$this->assertEquals(1, count($data));
$expectedPath = '/Shared' . $this->subfolder;
$expectedPath = $this->subfolder;
$this->assertEquals($expectedPath, $data[0]['path']);
// cleanup
@ -444,7 +444,7 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
$this->assertTrue(is_string($result));
$_GET['path'] = '/Shared';
$_GET['path'] = '/';
$_GET['subfiles'] = 'true';
$result = Share\Api::getAllShares(array());
@ -457,7 +457,7 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
// we should get exactly one result
$this->assertEquals(1, count($data));
$expectedPath = '/Shared' . $this->subsubfolder;
$expectedPath = $this->subsubfolder;
$this->assertEquals($expectedPath, $data[0]['path']);
@ -512,8 +512,8 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
$this->assertTrue(is_string($result));
// ask for shared/subfolder
$expectedPath1 = '/Shared' . $this->subfolder;
// ask for subfolder
$expectedPath1 = $this->subfolder;
$_GET['path'] = $expectedPath1;
$result1 = Share\Api::getAllShares(array());
@ -524,8 +524,8 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
$data1 = $result1->getData();
$share1 = reset($data1);
// ask for shared/folder/subfolder
$expectedPath2 = '/Shared' . $this->folder . $this->subfolder;
// ask for folder/subfolder
$expectedPath2 = $this->folder . $this->subfolder;
$_GET['path'] = $expectedPath2;
$result2 = Share\Api::getAllShares(array());
@ -595,7 +595,7 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
$this->assertTrue(is_string($result));
$_GET['path'] = '/Shared';
$_GET['path'] = '/';
$_GET['subfiles'] = 'true';
$result = Share\Api::getAllShares(array());
@ -608,7 +608,7 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
// we should get exactly one result
$this->assertEquals(1, count($data));
$expectedPath = '/Shared' . $this->filename;
$expectedPath = $this->filename;
$this->assertEquals($expectedPath, $data[0]['path']);
@ -868,46 +868,4 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
}
function testCorrectPath() {
$path = "/foo/bar/test.txt";
$folder = "/correct/path";
$expectedResult = "/correct/path/test.txt";
$shareApiDummy = new TestShareApi();
$this->assertSame($expectedResult, $shareApiDummy->correctPathTest($path, $folder));
}
/**
* @expectedException \Exception
*/
public function testShareNonExisting() {
\Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
$id = PHP_INT_MAX - 1;
\OCP\Share::shareItem('file', $id, \OCP\Share::SHARE_TYPE_LINK, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
}
/**
* @expectedException \Exception
*/
public function testShareNotOwner() {
\Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
\OC\Files\Filesystem::file_put_contents('foo.txt', 'bar');
$info = \OC\Files\Filesystem::getFileInfo('foo.txt');
\Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
\OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_LINK, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
}
}
/**
* @brief dumnmy class to test protected methods
*/
class TestShareApi extends \OCA\Files\Share\Api {
public function correctPathTest($path, $folder) {
return self::correctPath($path, $folder);
}
}

@ -102,22 +102,20 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
* @param bool $password
*/
protected static function loginHelper($user, $create = false, $password = false) {
if ($create) {
\OC_User::createUser($user, $user);
}
if ($password === false) {
$password = $user;
}
if ($create) {
\OC_User::createUser($user, $password);
}
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_Util::setupFS($user);
\OC_User::setUserId($user);
$params['uid'] = $user;
$params['password'] = $password;
\OC_Util::setupFS($user);
}
/**

@ -68,7 +68,7 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
// retrieve the shared storage
$secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
list($this->sharedStorage, $internalPath) = $secondView->resolvePath('files/Shared/shareddir');
list($this->sharedStorage, $internalPath) = $secondView->resolvePath('files/shareddir');
$this->sharedCache = $this->sharedStorage->getCache();
}
@ -98,46 +98,46 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
function testSearchByMime() {
$results = $this->sharedStorage->getCache()->searchByMime('text');
$check = array(
array(
'name' => 'shared single file.txt',
'path' => 'shared single file.txt'
),
array(
'name' => 'bar.txt',
'path' => 'shareddir/bar.txt'
'path' => 'files/shareddir/bar.txt'
),
array(
'name' => 'another too.txt',
'path' => 'shareddir/subdir/another too.txt'
'path' => 'files/shareddir/subdir/another too.txt'
),
array(
'name' => 'another.txt',
'path' => 'shareddir/subdir/another.txt'
'path' => 'files/shareddir/subdir/another.txt'
),
);
$this->verifyFiles($check, $results);
$results2 = $this->sharedStorage->getCache()->searchByMime('text/plain');
$this->verifyFiles($check, $results);
}
function testGetFolderContentsInRoot() {
$results = $this->user2View->getDirectoryContent('/Shared/');
$results = $this->user2View->getDirectoryContent('/');
// we should get the shared items "shareddir" and "shared single file.txt"
// additional root will always contain the example file "welcome.txt",
// so this will be part of the result
$this->verifyFiles(
array(
array(
'name' => 'welcome.txt',
'path' => 'files/welcome.txt',
'mimetype' => 'text/plain',
),
array(
'name' => 'shareddir',
'path' => '/shareddir',
'path' => 'files/shareddir',
'mimetype' => 'httpd/unix-directory',
'usersPath' => 'files/Shared/shareddir'
),
array(
'name' => 'shared single file.txt',
'path' => '/shared single file.txt',
'path' => 'files/shared single file.txt',
'mimetype' => 'text/plain',
'usersPath' => 'files/Shared/shared single file.txt'
),
),
$results
@ -145,27 +145,24 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
}
function testGetFolderContentsInSubdir() {
$results = $this->user2View->getDirectoryContent('/Shared/shareddir');
$results = $this->user2View->getDirectoryContent('/shareddir');
$this->verifyFiles(
array(
array(
'name' => 'bar.txt',
'path' => 'files/container/shareddir/bar.txt',
'path' => 'files/shareddir/bar.txt',
'mimetype' => 'text/plain',
'usersPath' => 'files/Shared/shareddir/bar.txt'
),
array(
'name' => 'emptydir',
'path' => 'files/container/shareddir/emptydir',
'path' => 'files/shareddir/emptydir',
'mimetype' => 'httpd/unix-directory',
'usersPath' => 'files/Shared/shareddir/emptydir'
),
array(
'name' => 'subdir',
'path' => 'files/container/shareddir/subdir',
'path' => 'files/shareddir/subdir',
'mimetype' => 'httpd/unix-directory',
'usersPath' => 'files/Shared/shareddir/subdir'
),
),
$results
@ -182,27 +179,24 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$thirdView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
$results = $thirdView->getDirectoryContent('/Shared/subdir');
$results = $thirdView->getDirectoryContent('/subdir');
$this->verifyFiles(
array(
array(
'name' => 'another too.txt',
'path' => 'files/container/shareddir/subdir/another too.txt',
'path' => 'files/subdir/another too.txt',
'mimetype' => 'text/plain',
'usersPath' => 'files/Shared/subdir/another too.txt'
),
array(
'name' => 'another.txt',
'path' => 'files/container/shareddir/subdir/another.txt',
'path' => 'files/subdir/another.txt',
'mimetype' => 'text/plain',
'usersPath' => 'files/Shared/subdir/another.txt'
),
array(
'name' => 'not a text file.xml',
'path' => 'files/container/shareddir/subdir/not a text file.xml',
'path' => 'files/subdir/not a text file.xml',
'mimetype' => 'application/xml',
'usersPath' => 'files/Shared/subdir/not a text file.xml'
),
),
$results
@ -254,8 +248,8 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists('/Shared/test.txt'));
list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/Shared/test.txt');
$this->assertTrue(\OC\Files\Filesystem::file_exists('/test.txt'));
list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/test.txt');
/**
* @var \OC\Files\Storage\Shared $sharedStorage
*/
@ -275,8 +269,8 @@ class Test_Files_Sharing_Cache extends Test_Files_Sharing_Base {
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists('/Shared/foo'));
list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/Shared/foo');
$this->assertTrue(\OC\Files\Filesystem::file_exists('/foo'));
list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
/**
* @var \OC\Files\Storage\Shared $sharedStorage
*/

@ -23,6 +23,9 @@ require_once __DIR__ . '/base.php';
class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base {
private $sharedStorageRestrictedShare;
private $sharedCacheRestrictedShare;
function setUp() {
parent::setUp();
@ -55,8 +58,10 @@ class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base {
// retrieve the shared storage
$this->secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
list($this->sharedStorage, $internalPath) = $this->secondView->resolvePath('files/Shared/shareddir');
list($this->sharedStorage, $internalPath) = $this->secondView->resolvePath('files/shareddir');
list($this->sharedStorageRestrictedShare, $internalPath) = $this->secondView->resolvePath('files/shareddirrestricted');
$this->sharedCache = $this->sharedStorage->getCache();
$this->sharedCacheRestrictedShare = $this->sharedStorageRestrictedShare->getCache();
}
function tearDown() {
@ -86,9 +91,9 @@ class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base {
$this->assertEquals(31, $sharedDirPerms);
$sharedDirPerms = $this->sharedStorage->getPermissions('shareddir/textfile.txt');
$this->assertEquals(31, $sharedDirPerms);
$sharedDirRestrictedPerms = $this->sharedStorage->getPermissions('shareddirrestricted');
$sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted');
$this->assertEquals(7, $sharedDirRestrictedPerms);
$sharedDirRestrictedPerms = $this->sharedStorage->getPermissions('shareddirrestricted/textfile.txt');
$sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted/textfile.txt');
$this->assertEquals(7, $sharedDirRestrictedPerms);
}
@ -96,12 +101,12 @@ class Test_Files_Sharing_Permissions extends Test_Files_Sharing_Base {
* Test that the permissions of shared directory are returned correctly
*/
function testGetDirectoryPermissions() {
$contents = $this->secondView->getDirectoryContent('files/Shared/shareddir');
$contents = $this->secondView->getDirectoryContent('files/shareddir');
$this->assertEquals('subdir', $contents[0]['name']);
$this->assertEquals(31, $contents[0]['permissions']);
$this->assertEquals('textfile.txt', $contents[1]['name']);
$this->assertEquals(31, $contents[1]['permissions']);
$contents = $this->secondView->getDirectoryContent('files/Shared/shareddirrestricted');
$contents = $this->secondView->getDirectoryContent('files/shareddirrestricted');
$this->assertEquals('subdir', $contents[0]['name']);
$this->assertEquals(7, $contents[0]['permissions']);
$this->assertEquals('textfile1.txt', $contents[1]['name']);

@ -48,7 +48,7 @@ class Test_Files_Sharing_Watcher extends Test_Files_Sharing_Base {
// retrieve the shared storage
$secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
list($this->sharedStorage, $internalPath) = $secondView->resolvePath('files/Shared/shareddir');
list($this->sharedStorage, $internalPath) = $secondView->resolvePath('files/shareddir');
$this->sharedCache = $this->sharedStorage->getCache();
}
@ -77,12 +77,12 @@ class Test_Files_Sharing_Watcher extends Test_Files_Sharing_Base {
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData);
$this->sharedCache->put('shareddir/bar.txt', array('storage_mtime' => 10));
$this->sharedStorage->file_put_contents('shareddir/bar.txt', $textData);
$this->sharedCache->put('shareddir', array('storage_mtime' => 10));
$this->sharedCache->put('bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
$this->sharedStorage->file_put_contents('bar.txt', $textData);
$this->sharedCache->put('', array('mtime' => 10, 'storage_mtime' => 10, 'size' => '-1', 'mimetype' => 'httpd/unix-directory'));
// run the propagation code
$result = $this->sharedStorage->getWatcher()->checkUpdate('shareddir');
$result = $this->sharedStorage->getWatcher()->checkUpdate('');
$this->assertTrue($result);
@ -94,7 +94,7 @@ class Test_Files_Sharing_Watcher extends Test_Files_Sharing_Base {
$this->assertEquals($initialSizes['files/container/shareddir'] + $dataLen, $newSizes['files/container/shareddir']);
// no more updates
$result = $this->sharedStorage->getWatcher()->checkUpdate('shareddir');
$result = $this->sharedStorage->getWatcher()->checkUpdate('');
$this->assertFalse($result);
}
@ -108,12 +108,12 @@ class Test_Files_Sharing_Watcher extends Test_Files_Sharing_Base {
$textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$dataLen = strlen($textData);
$this->sharedCache->put('shareddir/subdir/bar.txt', array('storage_mtime' => 10));
$this->sharedStorage->file_put_contents('shareddir/subdir/bar.txt', $textData);
$this->sharedCache->put('shareddir/subdir', array('storage_mtime' => 10));
$this->sharedCache->put('subdir/bar.txt', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
$this->sharedStorage->file_put_contents('subdir/bar.txt', $textData);
$this->sharedCache->put('subdir', array('mtime' => 10, 'storage_mtime' => 10, 'size' => $dataLen, 'mimetype' => 'text/plain'));
// run the propagation code
$result = $this->sharedStorage->getWatcher()->checkUpdate('shareddir/subdir');
$result = $this->sharedStorage->getWatcher()->checkUpdate('subdir');
$this->assertTrue($result);
@ -126,20 +126,9 @@ class Test_Files_Sharing_Watcher extends Test_Files_Sharing_Base {
$this->assertEquals($initialSizes['files/container/shareddir/subdir'] + $dataLen, $newSizes['files/container/shareddir/subdir']);
// no more updates
$result = $this->sharedStorage->getWatcher()->checkUpdate('shareddir/subdir');
$this->assertFalse($result);
}
function testNoUpdateOnRoot() {
// no updates when called for root path
$result = $this->sharedStorage->getWatcher()->checkUpdate('');
$result = $this->sharedStorage->getWatcher()->checkUpdate('subdir');
$this->assertFalse($result);
// FIXME: for some reason when running this "naked" test,
// there will be remaining nonsensical entries in the
// database with a path "test-share-user1/container/..."
}
/**

@ -1177,10 +1177,6 @@ class Share extends \OC\Share\Constants {
// Remove root from file source paths if retrieving own shared items
if (isset($uidOwner) && isset($row['path'])) {
if (isset($row['parent'])) {
// FIXME: Doesn't always construct the correct path, example:
// Folder '/a/b', share '/a' and '/a/b' to user2
// user2 reshares /Shared/b and ask for share status of /Shared/a/b
// expected result: path=/Shared/a/b; actual result /Shared/b because of the parent
$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
$parentResult = $query->execute(array($row['parent']));
if (\OC_DB::isError($result)) {
@ -1189,7 +1185,7 @@ class Share extends \OC\Share\Constants {
\OC_Log::ERROR);
} else {
$parentRow = $parentResult->fetchRow();
$tmpPath = '/Shared' . $parentRow['file_target'];
$tmpPath = $parentRow['file_target'];
// find the right position where the row path continues from the target path
$pos = strrpos($row['path'], $parentRow['file_target']);
$subPath = substr($row['path'], $pos);

Loading…
Cancel
Save