aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/ajax/download.php4
-rw-r--r--apps/files/index.php1
-rw-r--r--apps/files_encryption/appinfo/app.php1
-rw-r--r--apps/files_external/appinfo/app.php2
-rw-r--r--apps/files_sharing/appinfo/app.php1
-rw-r--r--apps/files_sharing/application.php35
-rw-r--r--apps/files_sharing/lib/middleware/sharingcheckmiddleware.php30
-rw-r--r--apps/files_sharing/tests/middleware/sharingcheckmiddleware.php36
-rw-r--r--apps/files_trashbin/appinfo/app.php2
-rw-r--r--apps/files_versions/appinfo/app.php1
-rw-r--r--apps/user_ldap/appinfo/app.php1
-rw-r--r--apps/user_webdavauth/appinfo/app.php2
-rw-r--r--lib/private/app.php8
-rw-r--r--lib/private/app/dependencyanalyzer.php2
-rw-r--r--lib/private/files/view.php31
-rw-r--r--lib/private/repair.php4
-rw-r--r--lib/private/util.php4
-rw-r--r--lib/public/irequest.php4
-rw-r--r--lib/repair/cleantags.php114
-rw-r--r--tests/lib/app.php53
-rw-r--r--tests/lib/files/view.php14
-rw-r--r--tests/lib/repair/cleantags.php143
22 files changed, 424 insertions, 69 deletions
diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php
index b2e144c4b8f..368257b95cd 100644
--- a/apps/files/ajax/download.php
+++ b/apps/files/ajax/download.php
@@ -25,8 +25,8 @@
OCP\User::checkLoggedIn();
\OC::$server->getSession()->close();
-$files = $_GET["files"];
-$dir = $_GET["dir"];
+$files = isset($_GET['files']) ? $_GET['files'] : '';
+$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$files_list = json_decode($files);
// in case we get only a single file
diff --git a/apps/files/index.php b/apps/files/index.php
index 767cb156ca2..fe2cd4f5543 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -29,7 +29,6 @@ OCP\User::checkLoggedIn();
OCP\Util::addStyle('files', 'files');
OCP\Util::addStyle('files', 'upload');
OCP\Util::addStyle('files', 'mobile');
-OCP\Util::addTranslations('files');
OCP\Util::addscript('files', 'app');
OCP\Util::addscript('files', 'file-upload');
OCP\Util::addscript('files', 'jquery.iframe-transport');
diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
index f2dc63c340d..842b1a1ff27 100644
--- a/apps/files_encryption/appinfo/app.php
+++ b/apps/files_encryption/appinfo/app.php
@@ -1,6 +1,5 @@
<?php
-\OCP\Util::addTranslations('files_encryption');
\OCP\Util::addscript('files_encryption', 'encryption');
\OCP\Util::addscript('files_encryption', 'detect-migration');
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index 0aafcad559a..9b5994338a1 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -21,8 +21,6 @@ OC::$CLASSPATH['OC\Files\Storage\SFTP'] = 'files_external/lib/sftp.php';
OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php';
OC::$CLASSPATH['OCA\Files\External\Api'] = 'files_external/lib/api.php';
-OCP\Util::addTranslations('files_external');
-
OCP\App::registerAdmin('files_external', 'settings');
if (OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes') == 'yes') {
OCP\App::registerPersonal('files_external', 'personal');
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 36d148dce96..83dc3441668 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -21,7 +21,6 @@ OC::$CLASSPATH['OCA\Files_Sharing\Exceptions\BrokenPath'] = 'files_sharing/lib/e
OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
-OCP\Util::addTranslations('files_sharing');
OCP\Util::addScript('files_sharing', 'share');
OCP\Util::addScript('files_sharing', 'external');
diff --git a/apps/files_sharing/application.php b/apps/files_sharing/application.php
index 773831d99b1..56ec448d6a9 100644
--- a/apps/files_sharing/application.php
+++ b/apps/files_sharing/application.php
@@ -29,21 +29,22 @@ class Application extends App {
parent::__construct('files_sharing', $urlParams);
$container = $this->getContainer();
+ $server = $container->getServer();
/**
* Controllers
*/
- $container->registerService('ShareController', function(SimpleContainer $c) {
+ $container->registerService('ShareController', function(SimpleContainer $c) use ($server) {
return new ShareController(
$c->query('AppName'),
$c->query('Request'),
$c->query('UserSession'),
- $c->query('ServerContainer')->getAppConfig(),
- $c->query('ServerContainer')->getConfig(),
+ $server->getAppConfig(),
+ $server->getConfig(),
$c->query('URLGenerator'),
- $c->query('ServerContainer')->getUserManager(),
- $c->query('ServerContainer')->getLogger(),
- $c->query('ServerContainer')->getActivityManager()
+ $server->getUserManager(),
+ $server->getLogger(),
+ $server->getActivityManager()
);
});
$container->registerService('ExternalSharesController', function(SimpleContainer $c) {
@@ -58,33 +59,33 @@ class Application extends App {
/**
* Core class wrappers
*/
- $container->registerService('UserSession', function(SimpleContainer $c) {
- return $c->query('ServerContainer')->getUserSession();
+ $container->registerService('UserSession', function(SimpleContainer $c) use ($server) {
+ return $server->getUserSession();
});
- $container->registerService('URLGenerator', function(SimpleContainer $c) {
- return $c->query('ServerContainer')->getUrlGenerator();
+ $container->registerService('URLGenerator', function(SimpleContainer $c) use ($server){
+ return $server->getUrlGenerator();
});
$container->registerService('IsIncomingShareEnabled', function(SimpleContainer $c) {
return Helper::isIncomingServer2serverShareEnabled();
});
- $container->registerService('ExternalManager', function(SimpleContainer $c) {
+ $container->registerService('ExternalManager', function(SimpleContainer $c) use ($server){
return new \OCA\Files_Sharing\External\Manager(
- \OC::$server->getDatabaseConnection(),
+ $server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
- \OC::$server->getUserSession(),
- \OC::$server->getHTTPHelper()
+ $server->getUserSession(),
+ $server->getHTTPHelper()
);
});
/**
* Middleware
*/
- $container->registerService('SharingCheckMiddleware', function(SimpleContainer $c){
+ $container->registerService('SharingCheckMiddleware', function(SimpleContainer $c) use ($server){
return new SharingCheckMiddleware(
$c->query('AppName'),
- $c->query('ServerContainer')->getAppConfig(),
- $c->getCoreApi()
+ $server->getConfig(),
+ $server->getAppManager()
);
});
diff --git a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php
index af79cd9e94a..3508407f2a0 100644
--- a/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php
+++ b/apps/files_sharing/lib/middleware/sharingcheckmiddleware.php
@@ -10,10 +10,10 @@
namespace OCA\Files_Sharing\Middleware;
-use OCP\AppFramework\IApi;
-use \OCP\AppFramework\Middleware;
+use OCP\App\IAppManager;
+use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\TemplateResponse;
-use OCP\IAppConfig;
+use OCP\IConfig;
/**
* Checks whether the "sharing check" is enabled
@@ -24,22 +24,22 @@ class SharingCheckMiddleware extends Middleware {
/** @var string */
protected $appName;
- /** @var IAppConfig */
- protected $appConfig;
- /** @var IApi */
- protected $api;
+ /** @var IConfig */
+ protected $config;
+ /** @var IAppManager */
+ protected $appManager;
/***
* @param string $appName
- * @param IAppConfig $appConfig
- * @param IApi $api
+ * @param IConfig $config
+ * @param IAppManager $appManager
*/
public function __construct($appName,
- IAppConfig $appConfig,
- IApi $api) {
+ IConfig $config,
+ IAppManager $appManager) {
$this->appName = $appName;
- $this->appConfig = $appConfig;
- $this->api = $api;
+ $this->config = $config;
+ $this->appManager = $appManager;
}
/**
@@ -69,12 +69,12 @@ class SharingCheckMiddleware extends Middleware {
private function isSharingEnabled() {
// FIXME: This check is done here since the route is globally defined and not inside the files_sharing app
// Check whether the sharing application is enabled
- if(!$this->api->isAppEnabled($this->appName)) {
+ if(!$this->appManager->isEnabledForUser($this->appName)) {
return false;
}
// Check whether public sharing is enabled
- if($this->appConfig->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
+ if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
return false;
}
diff --git a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php
index 90c9a7bba10..466904889af 100644
--- a/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php
+++ b/apps/files_sharing/tests/middleware/sharingcheckmiddleware.php
@@ -14,34 +14,34 @@ namespace OCA\Files_Sharing\Middleware;
/**
* @package OCA\Files_Sharing\Middleware\SharingCheckMiddleware
*/
-class SharingCheckMiddlewareTest extends \PHPUnit_Framework_TestCase {
+class SharingCheckMiddlewareTest extends \Test\TestCase {
- /** @var \OCP\IAppConfig */
- private $appConfig;
- /** @var \OCP\AppFramework\IApi */
- private $api;
+ /** @var \OCP\IConfig */
+ private $config;
+ /** @var \OCP\App\IAppManager */
+ private $appManager;
/** @var SharingCheckMiddleware */
private $sharingCheckMiddleware;
protected function setUp() {
- $this->appConfig = $this->getMockBuilder('\OCP\IAppConfig')
+ $this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
- $this->api = $this->getMockBuilder('\OCP\AppFramework\IApi')
+ $this->appManager = $this->getMockBuilder('\OCP\App\IAppManager')
->disableOriginalConstructor()->getMock();
- $this->sharingCheckMiddleware = new SharingCheckMiddleware('files_sharing', $this->appConfig, $this->api);
+ $this->sharingCheckMiddleware = new SharingCheckMiddleware('files_sharing', $this->config, $this->appManager);
}
public function testIsSharingEnabledWithEverythingEnabled() {
- $this->api
+ $this->appManager
->expects($this->once())
- ->method('isAppEnabled')
+ ->method('isEnabledForUser')
->with('files_sharing')
->will($this->returnValue(true));
- $this->appConfig
+ $this->config
->expects($this->once())
- ->method('getValue')
+ ->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('yes'));
@@ -49,9 +49,9 @@ class SharingCheckMiddlewareTest extends \PHPUnit_Framework_TestCase {
}
public function testIsSharingEnabledWithAppDisabled() {
- $this->api
+ $this->appManager
->expects($this->once())
- ->method('isAppEnabled')
+ ->method('isEnabledForUser')
->with('files_sharing')
->will($this->returnValue(false));
@@ -59,15 +59,15 @@ class SharingCheckMiddlewareTest extends \PHPUnit_Framework_TestCase {
}
public function testIsSharingEnabledWithSharingDisabled() {
- $this->api
+ $this->appManager
->expects($this->once())
- ->method('isAppEnabled')
+ ->method('isEnabledForUser')
->with('files_sharing')
->will($this->returnValue(true));
- $this->appConfig
+ $this->config
->expects($this->once())
- ->method('getValue')
+ ->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('no'));
diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php
index 0e2cbaa529f..da502f0c11e 100644
--- a/apps/files_trashbin/appinfo/app.php
+++ b/apps/files_trashbin/appinfo/app.php
@@ -1,8 +1,6 @@
<?php
$l = \OC::$server->getL10N('files_trashbin');
-OCP\Util::addTranslations('files_trashbin');
-
// register hooks
\OCA\Files_Trashbin\Trashbin::registerHooks();
diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php
index ae29bceb37c..e13dc64c46e 100644
--- a/apps/files_versions/appinfo/app.php
+++ b/apps/files_versions/appinfo/app.php
@@ -1,6 +1,5 @@
<?php
-OCP\Util::addTranslations('files_versions');
OCP\Util::addscript('files_versions', 'versions');
OCP\Util::addStyle('files_versions', 'versions');
diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php
index 911688a5c20..6895cdbe843 100644
--- a/apps/user_ldap/appinfo/app.php
+++ b/apps/user_ldap/appinfo/app.php
@@ -57,7 +57,6 @@ if(count($configPrefixes) > 0) {
OC_Group::useBackend($groupBackend);
}
-OCP\Util::addTranslations('user_ldap');
OCP\Backgroundjob::registerJob('OCA\user_ldap\lib\Jobs');
OCP\Backgroundjob::registerJob('\OCA\User_LDAP\Jobs\CleanUp');
diff --git a/apps/user_webdavauth/appinfo/app.php b/apps/user_webdavauth/appinfo/app.php
index 125f5f40654..3cd227bddbe 100644
--- a/apps/user_webdavauth/appinfo/app.php
+++ b/apps/user_webdavauth/appinfo/app.php
@@ -28,8 +28,6 @@ OC_APP::registerAdmin('user_webdavauth', 'settings');
OC_User::registerBackend("WEBDAVAUTH");
OC_User::useBackend( "WEBDAVAUTH" );
-OCP\Util::addTranslations('user_webdavauth');
-
// add settings page to navigation
$entry = array(
'id' => "user_webdavauth_settings",
diff --git a/lib/private/app.php b/lib/private/app.php
index ecdc8ca8320..34226260689 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -1022,13 +1022,17 @@ class OC_App {
public static function isAppCompatible($ocVersion, $appInfo){
$requireMin = '';
$requireMax = '';
- if (isset($appInfo['requiremin'])) {
+ if (isset($appInfo['dependencies']['owncloud']['@attributes']['min-version'])) {
+ $requireMin = $appInfo['dependencies']['owncloud']['@attributes']['min-version'];
+ } else if (isset($appInfo['requiremin'])) {
$requireMin = $appInfo['requiremin'];
} else if (isset($appInfo['require'])) {
$requireMin = $appInfo['require'];
}
- if (isset($appInfo['requiremax'])) {
+ if (isset($appInfo['dependencies']['owncloud']['@attributes']['max-version'])) {
+ $requireMax = $appInfo['dependencies']['owncloud']['@attributes']['max-version'];
+ } else if (isset($appInfo['requiremax'])) {
$requireMax = $appInfo['requiremax'];
}
diff --git a/lib/private/app/dependencyanalyzer.php b/lib/private/app/dependencyanalyzer.php
index ae40e8523fc..e4564c4e036 100644
--- a/lib/private/app/dependencyanalyzer.php
+++ b/lib/private/app/dependencyanalyzer.php
@@ -182,6 +182,8 @@ class DependencyAnalyzer {
$minVersion = $dependencies['owncloud']['@attributes']['min-version'];
} elseif (isset($appInfo['requiremin'])) {
$minVersion = $appInfo['requiremin'];
+ } elseif (isset($appInfo['require'])) {
+ $minVersion = $appInfo['require'];
}
$maxVersion = null;
if (isset($dependencies['owncloud']['@attributes']['max-version'])) {
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 57441c8e680..76b7d34e756 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -906,6 +906,9 @@ class View {
if (!Filesystem::isValidPath($path)) {
return $data;
}
+ if (Cache\Scanner::isPartialFile($path)) {
+ return $this->getPartFileInfo($path);
+ }
$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
$mount = Filesystem::getMountManager()->find($path);
@@ -1318,4 +1321,32 @@ class View {
return $result;
}
+
+ /**
+ * Get a fileinfo object for files that are ignored in the cache (part files)
+ *
+ * @param string $path
+ * @return \OCP\Files\FileInfo
+ */
+ private function getPartFileInfo($path) {
+ $mount = $this->getMount($path);
+ $storage = $mount->getStorage();
+ $internalPath = $mount->getInternalPath($this->getAbsolutePath($path));
+ return new FileInfo(
+ $this->getAbsolutePath($path),
+ $storage,
+ $internalPath,
+ [
+ 'fileid' => null,
+ 'mimetype' => $storage->getMimeType($internalPath),
+ 'name' => basename($path),
+ 'etag' => null,
+ 'size' => $storage->filesize($internalPath),
+ 'mtime' => $storage->filemtime($internalPath),
+ 'encrypted' => false,
+ 'permissions' => \OCP\Constants::PERMISSION_ALL
+ ],
+ $mount
+ );
+ }
}
diff --git a/lib/private/repair.php b/lib/private/repair.php
index c4f057b53ae..d9fd99707e8 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -11,6 +11,7 @@ namespace OC;
use OC\Hooks\BasicEmitter;
use OC\Hooks\Emitter;
use OC\Repair\AssetCache;
+use OC\Repair\CleanTags;
use OC\Repair\Collation;
use OC\Repair\FillETags;
use OC\Repair\InnoDB;
@@ -81,7 +82,8 @@ class Repair extends BasicEmitter {
new RepairLegacyStorages(\OC::$server->getConfig(), \OC_DB::getConnection()),
new RepairConfig(),
new AssetCache(),
- new FillETags(\OC_DB::getConnection())
+ new FillETags(\OC_DB::getConnection()),
+ new CleanTags(\OC_DB::getConnection()),
);
}
diff --git a/lib/private/util.php b/lib/private/util.php
index d2d286fc11e..3b943f046bf 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -362,6 +362,10 @@ class OC_Util {
public static function addScript($application, $file = null) {
$path = OC_Util::generatePath($application, 'js', $file);
if (!in_array($path, self::$scripts)) {
+ // core js files need separate handling
+ if ($application !== 'core' && $file !== null) {
+ self::addTranslations($application);
+ }
self::$scripts[] = $path;
}
}
diff --git a/lib/public/irequest.php b/lib/public/irequest.php
index d77a9bc887a..a2b89e09f52 100644
--- a/lib/public/irequest.php
+++ b/lib/public/irequest.php
@@ -51,8 +51,10 @@ namespace OCP;
* - When accessing ->patch and the Content-Type is either application/json
* or application/x-www-form-urlencoded (most cases) it will act like ->get
* and ->post and return an array. Otherwise the raw data will be returned.
+ *
+ * @property-read string[] $server
+ *
*/
-
interface IRequest {
/**
diff --git a/lib/repair/cleantags.php b/lib/repair/cleantags.php
new file mode 100644
index 00000000000..6aa325df0b6
--- /dev/null
+++ b/lib/repair/cleantags.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Repair;
+
+use OC\DB\Connection;
+use OC\Hooks\BasicEmitter;
+use OC\RepairStep;
+
+/**
+ * Class RepairConfig
+ *
+ * @package OC\Repair
+ */
+class CleanTags extends BasicEmitter implements RepairStep {
+
+ /** @var Connection */
+ protected $connection;
+
+ /**
+ * @param Connection $connection
+ */
+ public function __construct(Connection $connection) {
+ $this->connection = $connection;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName() {
+ return 'Clean tags and favorites';
+ }
+
+ /**
+ * Updates the configuration after running an update
+ */
+ public function run() {
+
+ // Delete tag entries for deleted files
+ $this->deleteOrphanEntries(
+ '%d tags for delete files have been removed.',
+ '*PREFIX*vcategory_to_object', 'objid',
+ '*PREFIX*filecache', 'fileid', 'fileid'
+ );
+
+ // Delete tag entries for deleted tags
+ $this->deleteOrphanEntries(
+ '%d tag entries for deleted tags have been removed.',
+ '*PREFIX*vcategory_to_object', 'categoryid',
+ '*PREFIX*vcategory', 'id', 'uid'
+ );
+
+ // Delete tags that have no entries
+ $this->deleteOrphanEntries(
+ '%d tags with no entries have been removed.',
+ '*PREFIX*vcategory', 'id',
+ '*PREFIX*vcategory_to_object', 'categoryid', 'type'
+ );
+ }
+
+ /**
+ * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
+ *
+ * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
+ * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
+ * is being deleted.
+ *
+ * @param string $repairInfo
+ * @param string $deleteTable
+ * @param string $deleteId
+ * @param string $sourceTable
+ * @param string $sourceId
+ * @param string $sourceNullColumn If this column is null in the source table,
+ * the entry is deleted in the $deleteTable
+ */
+ protected function deleteOrphanEntries($repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
+ $qb = $this->connection->createQueryBuilder();
+
+ $qb->select('d.' . $deleteId)
+ ->from($deleteTable, 'd')
+ ->leftJoin('d', $sourceTable, 's', 'd.' . $deleteId . ' = s.' . $sourceId)
+ ->where(
+ 'd.type = ' . $qb->expr()->literal('files')
+ )
+ ->andWhere(
+ $qb->expr()->isNull('s.' . $sourceNullColumn)
+ );
+ $result = $qb->execute();
+
+ $orphanItems = array();
+ while ($row = $result->fetch()) {
+ $orphanItems[] = (int) $row[$deleteId];
+ }
+
+ if (!empty($orphanItems)) {
+ $orphanItemsBatch = array_chunk($orphanItems, 200);
+ foreach ($orphanItemsBatch as $items) {
+ $qb->delete($deleteTable)
+ ->where($qb->expr()->in($deleteId, ':ids'));
+ $qb->setParameter('ids', $items, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY);
+ $qb->execute();
+ }
+ }
+
+ if ($repairInfo) {
+ $this->emit('\OC\Repair', 'info', array(sprintf($repairInfo, sizeof($orphanItems))));
+ }
+ }
+}
diff --git a/tests/lib/app.php b/tests/lib/app.php
index 23c1a340e03..1bd350f216a 100644
--- a/tests/lib/app.php
+++ b/tests/lib/app.php
@@ -112,7 +112,7 @@ class Test_App extends \Test\TestCase {
),
true
),
- // multiple OC number
+ // multiple OC number
array(
'4.3.1',
array(
@@ -120,7 +120,7 @@ class Test_App extends \Test\TestCase {
),
true
),
- // single app number
+ // single app number
array(
'4',
array(
@@ -208,6 +208,55 @@ class Test_App extends \Test\TestCase {
),
true
),
+ // dependencies versions before require*
+ array(
+ '6.0.0.0',
+ array(
+ 'requiremin' => '5.0',
+ 'requiremax' => '7.0',
+ 'dependencies' => array(
+ 'owncloud' => array(
+ '@attributes' => array(
+ 'min-version' => '7.0',
+ 'max-version' => '7.0',
+ ),
+ ),
+ ),
+ ),
+ false
+ ),
+ array(
+ '6.0.0.0',
+ array(
+ 'requiremin' => '5.0',
+ 'requiremax' => '7.0',
+ 'dependencies' => array(
+ 'owncloud' => array(
+ '@attributes' => array(
+ 'min-version' => '5.0',
+ 'max-version' => '5.0',
+ ),
+ ),
+ ),
+ ),
+ false
+ ),
+ array(
+ '6.0.0.0',
+ array(
+ 'requiremin' => '5.0',
+ 'requiremax' => '5.0',
+ 'dependencies' => array(
+ 'owncloud' => array(
+ '@attributes' => array(
+ 'min-version' => '5.0',
+ 'max-version' => '7.0',
+ ),
+ ),
+ ),
+ ),
+ true
+ ),
);
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 25065967260..3ff19d7385d 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -703,6 +703,20 @@ class View extends \Test\TestCase {
$this->assertEquals($expectedPath, $view->getAbsolutePath($relativePath));
}
+ public function testPartFileInfo() {
+ $storage = new Temporary(array());
+ $scanner = $storage->getScanner();
+ \OC\Files\Filesystem::mount($storage, array(), '/test/');
+ $storage->file_put_contents('test.part', 'foobar');
+ $scanner->scan('');
+ $view = new \OC\Files\View('/test');
+ $info = $view->getFileInfo('test.part');
+
+ $this->assertInstanceOf('\OCP\Files\FileInfo', $info);
+ $this->assertNull($info->getId());
+ $this->assertEquals(6, $info->getSize());
+ }
+
function absolutePathProvider() {
return array(
array('/files/', ''),
diff --git a/tests/lib/repair/cleantags.php b/tests/lib/repair/cleantags.php
new file mode 100644
index 00000000000..29a1a8b432e
--- /dev/null
+++ b/tests/lib/repair/cleantags.php
@@ -0,0 +1,143 @@
+<?php
+/**
+ * Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Repair;
+
+/**
+ * Tests for the cleaning the tags tables
+ *
+ * @see \OC\Repair\CleanTags
+ */
+class CleanTags extends \Test\TestCase {
+
+ /** @var \OC\RepairStep */
+ private $repair;
+
+ /** @var \Doctrine\DBAL\Connection */
+ private $connection;
+
+ /** @var array */
+ protected $tagCategories;
+
+ /** @var int */
+ protected $createdFile;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->connection = \OC::$server->getDatabaseConnection();
+ $this->repair = new \OC\Repair\CleanTags($this->connection);
+ }
+
+ protected function tearDown() {
+ $qb = $this->connection->createQueryBuilder();
+ $qb->delete('*PREFIX*vcategory')
+ ->where('uid = ' . $qb->createNamedParameter('TestRepairCleanTags'))
+ ->execute();
+
+ $qb->delete('*PREFIX*vcategory_to_object')
+ ->where($qb->expr()->in('categoryid', ':ids'));
+ $qb->setParameter('ids', $this->tagCategories, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY);
+ $qb->execute();
+
+ $qb->delete('*PREFIX*filecache')
+ ->where('fileid = ' . $qb->createNamedParameter($this->createdFile, \PDO::PARAM_INT))
+ ->execute();
+
+ parent::tearDown();
+ }
+
+ public function testRun() {
+ $cat1 = $this->addTagCategory('TestRepairCleanTags', 'files'); // Retained
+ $cat2 = $this->addTagCategory('TestRepairCleanTags2', 'files'); // Deleted: Category is empty
+ $cat3 = $this->addTagCategory('TestRepairCleanTags', 'contacts'); // Retained
+ $file = $this->getFileID();
+
+ $this->addTagEntry($file, $cat2, 'files'); // Retained
+ $this->addTagEntry($file + 1, $cat1, 'files'); // Deleted: File is NULL
+ $this->addTagEntry(9999999, $cat3, 'contacts'); // Retained
+ $this->addTagEntry($file, $cat3 + 1, 'files'); // Deleted: Category is NULL
+
+ $this->assertEntryCount('*PREFIX*vcategory', 3, 'Assert tag categories count before repair step');
+ $this->assertEntryCount('*PREFIX*vcategory_to_object', 4, 'Assert tag entries count before repair step');
+ $this->repair->run();
+ $this->assertEntryCount('*PREFIX*vcategory', 2, 'Assert tag categories count after repair step');
+ $this->assertEntryCount('*PREFIX*vcategory_to_object', 2, 'Assert tag entries count after repair step');
+ }
+
+ /**
+ * @param string $tableName
+ * @param int $expected
+ * @param string $message
+ */
+ protected function assertEntryCount($tableName, $expected, $message = '') {
+ $qb = $this->connection->createQueryBuilder();
+ $result = $qb->select('COUNT(*)')
+ ->from($tableName)
+ ->execute();
+
+ $this->assertEquals($expected, $result->fetchColumn(), $message);
+ }
+
+ /**
+ * Adds a new tag category to the database
+ *
+ * @param string $category
+ * @param string $type
+ * @return int
+ */
+ protected function addTagCategory($category, $type) {
+ $qb = $this->connection->createQueryBuilder();
+ $qb->insert('*PREFIX*vcategory')
+ ->values([
+ 'uid' => $qb->createNamedParameter('TestRepairCleanTags'),
+ 'category' => $qb->createNamedParameter($category),
+ 'type' => $qb->createNamedParameter($type),
+ ])
+ ->execute();
+
+ $id = (int) $this->connection->lastInsertId();
+ $this->tagCategories[] = $id;
+ return $id;
+ }
+
+ /**
+ * Adds a new tag entry to the database
+ * @param int $objectId
+ * @param int $category
+ * @param string $type
+ */
+ protected function addTagEntry($objectId, $category, $type) {
+ $qb = $this->connection->createQueryBuilder();
+ $qb->insert('*PREFIX*vcategory_to_object')
+ ->values([
+ 'objid' => $qb->createNamedParameter($objectId, \PDO::PARAM_INT),
+ 'categoryid' => $qb->createNamedParameter($category, \PDO::PARAM_INT),
+ 'type' => $qb->createNamedParameter($type),
+ ])
+ ->execute();
+ }
+
+ /**
+ * Gets the last fileid from the file cache
+ *
+ * @return int
+ */
+ protected function getFileID() {
+ $qb = $this->connection->createQueryBuilder();
+
+ // We create a new file entry and delete it after the test again
+ $qb->insert('*PREFIX*filecache')
+ ->values([
+ 'path' => $qb->createNamedParameter('TestRepairCleanTags'),
+ ])
+ ->execute();
+ $this->createdFile = (int) $this->connection->lastInsertId();
+ return $this->createdFile;
+ }
+}