diff options
Diffstat (limited to 'apps/files_versions')
17 files changed, 20 insertions, 55 deletions
diff --git a/apps/files_versions/lib/AppInfo/Application.php b/apps/files_versions/lib/AppInfo/Application.php index 040b72a8f0a..36d7b6d2767 100644 --- a/apps/files_versions/lib/AppInfo/Application.php +++ b/apps/files_versions/lib/AppInfo/Application.php @@ -42,7 +42,6 @@ use OCP\AppFramework\IAppContainer; use OCP\EventDispatcher\IEventDispatcher; class Application extends App { - const APP_ID = 'files_versions'; public function __construct(array $urlParams = []) { @@ -95,11 +94,11 @@ class Application extends App { public function registerVersionBackends() { $server = $this->getContainer()->getServer(); $appManager = $server->getAppManager(); - foreach($appManager->getInstalledApps() as $app) { + foreach ($appManager->getInstalledApps() as $app) { $appInfo = $appManager->getAppInfo($app); if (isset($appInfo['versions'])) { $backends = $appInfo['versions']; - foreach($backends as $backend) { + foreach ($backends as $backend) { if (isset($backend['@value'])) { $this->loadBackend($backend); } else { @@ -131,5 +130,4 @@ class Application extends App { $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); } - } diff --git a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php index eb4287376e9..4c8f82a1c76 100644 --- a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php +++ b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php @@ -31,7 +31,6 @@ use OCP\IUser; use OCP\IUserManager; class ExpireVersions extends \OC\BackgroundJob\TimedJob { - const ITEMS_PER_SESSION = 1000; /** diff --git a/apps/files_versions/lib/Command/CleanUp.php b/apps/files_versions/lib/Command/CleanUp.php index b5b8f3dcfdb..397a1450578 100644 --- a/apps/files_versions/lib/Command/CleanUp.php +++ b/apps/files_versions/lib/Command/CleanUp.php @@ -61,7 +61,6 @@ class CleanUp extends Command { protected function execute(InputInterface $input, OutputInterface $output) { - $users = $input->getArgument('user_id'); if (!empty($users)) { foreach ($users as $user) { @@ -110,5 +109,4 @@ class CleanUp extends Command { $this->rootFolder->get('/' . $user . '/files_versions')->delete(); } } - } diff --git a/apps/files_versions/lib/Command/ExpireVersions.php b/apps/files_versions/lib/Command/ExpireVersions.php index d67542db259..944e0136691 100644 --- a/apps/files_versions/lib/Command/ExpireVersions.php +++ b/apps/files_versions/lib/Command/ExpireVersions.php @@ -70,7 +70,6 @@ class ExpireVersions extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - $maxAge = $this->expiration->getMaxAgeAsTimestamp(); if (!$maxAge) { $output->writeln("No expiry configured."); diff --git a/apps/files_versions/lib/Events/CreateVersionEvent.php b/apps/files_versions/lib/Events/CreateVersionEvent.php index 4f6ddd4367b..90281bd8ca7 100644 --- a/apps/files_versions/lib/Events/CreateVersionEvent.php +++ b/apps/files_versions/lib/Events/CreateVersionEvent.php @@ -78,5 +78,4 @@ class CreateVersionEvent extends Event { public function shouldCreateVersion() { return $this->createVersion; } - } diff --git a/apps/files_versions/lib/Expiration.php b/apps/files_versions/lib/Expiration.php index a56042e76b8..c9c91d67d7f 100644 --- a/apps/files_versions/lib/Expiration.php +++ b/apps/files_versions/lib/Expiration.php @@ -164,7 +164,7 @@ class Expiration { ); } - if (!$isValid){ + if (!$isValid) { $minValue = 'auto'; $maxValue = 'auto'; } diff --git a/apps/files_versions/lib/Hooks.php b/apps/files_versions/lib/Hooks.php index 179a404ed9a..0603228192c 100644 --- a/apps/files_versions/lib/Hooks.php +++ b/apps/files_versions/lib/Hooks.php @@ -40,7 +40,6 @@ use OC\Files\View; use OCP\Util; class Hooks { - public static function connectHooks() { // Listen to write signals Util::connectHook('OC_Filesystem', 'write', Hooks::class, 'write_hook'); @@ -58,7 +57,7 @@ class Hooks { */ public static function write_hook($params) { $path = $params[Filesystem::signal_param_path]; - if($path !== '') { + if ($path !== '') { Storage::store($path); } } @@ -73,7 +72,7 @@ class Hooks { */ public static function remove_hook($params) { $path = $params[Filesystem::signal_param_path]; - if($path !== '') { + if ($path !== '') { Storage::delete($path); } } @@ -84,9 +83,9 @@ class Hooks { */ public static function pre_remove_hook($params) { $path = $params[Filesystem::signal_param_path]; - if($path !== '') { - Storage::markDeletedFile($path); - } + if ($path !== '') { + Storage::markDeletedFile($path); + } } /** @@ -99,7 +98,7 @@ class Hooks { public static function rename_hook($params) { $oldpath = $params['oldpath']; $newpath = $params['newpath']; - if($oldpath !== '' && $newpath !== '') { + if ($oldpath !== '' && $newpath !== '') { Storage::renameOrCopy($oldpath, $newpath, 'rename'); } } @@ -114,7 +113,7 @@ class Hooks { public static function copy_hook($params) { $oldpath = $params['oldpath']; $newpath = $params['newpath']; - if($oldpath !== '' && $newpath !== '') { + if ($oldpath !== '' && $newpath !== '') { Storage::renameOrCopy($oldpath, $newpath, 'copy'); } } diff --git a/apps/files_versions/lib/Listener/LoadAdditionalListener.php b/apps/files_versions/lib/Listener/LoadAdditionalListener.php index f6d67341074..bebd98eaca9 100644 --- a/apps/files_versions/lib/Listener/LoadAdditionalListener.php +++ b/apps/files_versions/lib/Listener/LoadAdditionalListener.php @@ -43,5 +43,4 @@ class LoadAdditionalListener implements IEventListener { // we properly split it between files list and sidebar Util::addScript(Application::APP_ID, 'files_versions'); } - } diff --git a/apps/files_versions/lib/Listener/LoadSidebarListener.php b/apps/files_versions/lib/Listener/LoadSidebarListener.php index 875fe8b3fc5..3ea696c0418 100644 --- a/apps/files_versions/lib/Listener/LoadSidebarListener.php +++ b/apps/files_versions/lib/Listener/LoadSidebarListener.php @@ -43,5 +43,4 @@ class LoadSidebarListener implements IEventListener { // we properly split it between files list and sidebar Util::addScript(Application::APP_ID, 'files_versions'); } - } diff --git a/apps/files_versions/lib/Sabre/Plugin.php b/apps/files_versions/lib/Sabre/Plugin.php index cde5e319c8f..41c3ff5a5a8 100644 --- a/apps/files_versions/lib/Sabre/Plugin.php +++ b/apps/files_versions/lib/Sabre/Plugin.php @@ -81,5 +81,4 @@ class Plugin extends ServerPlugin { . '; filename="' . rawurlencode($filename) . '"'); } } - } diff --git a/apps/files_versions/lib/Sabre/RestoreFolder.php b/apps/files_versions/lib/Sabre/RestoreFolder.php index 89f379e3c1c..5b52a5777ae 100644 --- a/apps/files_versions/lib/Sabre/RestoreFolder.php +++ b/apps/files_versions/lib/Sabre/RestoreFolder.php @@ -77,5 +77,4 @@ class RestoreFolder implements ICollection, IMoveTarget { $sourceNode->rollBack(); return true; } - } diff --git a/apps/files_versions/lib/Sabre/RootCollection.php b/apps/files_versions/lib/Sabre/RootCollection.php index e305b758c8d..fb68e0f0bfc 100644 --- a/apps/files_versions/lib/Sabre/RootCollection.php +++ b/apps/files_versions/lib/Sabre/RootCollection.php @@ -81,5 +81,4 @@ class RootCollection extends AbstractPrincipalCollection { public function getName() { return 'versions'; } - } diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index a149e352e3d..f62650e539d 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -57,7 +57,6 @@ use OCP\Lock\ILockingProvider; use OCP\User; class Storage { - const DEFAULTENABLED=true; const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota const VERSIONS_ROOT = 'files_versions/'; @@ -139,7 +138,6 @@ class Storage { * @return array with user id and path */ public static function getSourcePathAndUser($source) { - if (isset(self::$sourcePathAndUser[$source])) { $uid = self::$sourcePathAndUser[$source]['uid']; $path = self::$sourcePathAndUser[$source]['path']; @@ -241,13 +239,11 @@ class Storage { * Delete versions of a file */ public static function delete($path) { - $deletedFile = self::$deletedFiles[$path]; $uid = $deletedFile['uid']; $filename = $deletedFile['filename']; if (!Filesystem::file_exists($path)) { - $view = new View('/' . $uid . '/files_versions'); $versions = self::getVersions($uid, $filename); @@ -318,7 +314,6 @@ class Storage { if (!$rootView->is_dir('/' . $targetOwner . '/files/' . $targetPath)) { self::scheduleExpire($targetOwner, $targetPath); } - } /** @@ -389,7 +384,6 @@ class Storage { } return false; - } /** @@ -531,7 +525,6 @@ class Storage { * @return string for example "5 days ago" */ private static function getHumanReadableTimestamp($timestamp) { - $diff = time() - $timestamp; if ($diff < 60) { // first minute @@ -549,7 +542,6 @@ class Storage { } else { return round($diff / 29030400) . " years ago"; } - } /** @@ -750,7 +742,7 @@ class Storage { if ($quota >= 0) { if ($softQuota) { $userFolder = \OC::$server->getUserFolder($uid); - if(is_null($userFolder)) { + if (is_null($userFolder)) { $availableSpace = 0; } else { $free = $quota - $userFolder->getSize(false); // remaining free space for user @@ -790,7 +782,7 @@ class Storage { } $logger = \OC::$server->getLogger(); - foreach($toDelete as $key => $path) { + foreach ($toDelete as $key => $path) { \OC_Hook::emit('\OCP\Versions', 'preDelete', ['path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]); self::deleteVersion($versionsFileview, $path); \OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED]); @@ -854,5 +846,4 @@ class Storage { } return self::$application->getContainer()->query(Expiration::class); } - } diff --git a/apps/files_versions/lib/Versions/BackendNotFoundException.php b/apps/files_versions/lib/Versions/BackendNotFoundException.php index 4b4bf96f1ce..5338d5eea37 100644 --- a/apps/files_versions/lib/Versions/BackendNotFoundException.php +++ b/apps/files_versions/lib/Versions/BackendNotFoundException.php @@ -24,5 +24,4 @@ namespace OCA\Files_Versions\Versions; class BackendNotFoundException extends \Exception { - } diff --git a/apps/files_versions/tests/Command/CleanupTest.php b/apps/files_versions/tests/Command/CleanupTest.php index 1fad960f952..89474954161 100644 --- a/apps/files_versions/tests/Command/CleanupTest.php +++ b/apps/files_versions/tests/Command/CleanupTest.php @@ -65,14 +65,13 @@ class CleanupTest extends TestCase { * @param boolean $nodeExists */ public function testDeleteVersions($nodeExists) { - $this->rootFolder->expects($this->once()) ->method('nodeExists') ->with('/testUser/files_versions') ->willReturn($nodeExists); - if($nodeExists) { + if ($nodeExists) { $this->rootFolder->expects($this->once()) ->method('get') ->with('/testUser/files_versions') @@ -167,5 +166,4 @@ class CleanupTest extends TestCase { $this->invokePrivate($instance, 'execute', [$inputInterface, $outputInterface]); } - } diff --git a/apps/files_versions/tests/Controller/PreviewControllerTest.php b/apps/files_versions/tests/Controller/PreviewControllerTest.php index 084bb25da82..64732ac8633 100644 --- a/apps/files_versions/tests/Controller/PreviewControllerTest.php +++ b/apps/files_versions/tests/Controller/PreviewControllerTest.php @@ -182,5 +182,4 @@ class PreviewControllerTest extends TestCase { $this->assertEquals($expected, $res); } - } diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index ae052335a95..c3ae186e73e 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -47,7 +47,6 @@ use OCP\IUser; * @group DB */ class VersioningTest extends \Test\TestCase { - const TEST_VERSIONS_USER = 'test-versions-user'; const TEST_VERSIONS_USER2 = 'test-versions-user2'; const USERS_VERSIONS_ROOT = '/test-versions-user/files_versions'; @@ -72,9 +71,13 @@ class VersioningTest extends \Test\TestCase { public static function tearDownAfterClass(): void { // cleanup test user $user = \OC::$server->getUserManager()->get(self::TEST_VERSIONS_USER); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } $user = \OC::$server->getUserManager()->get(self::TEST_VERSIONS_USER2); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } parent::tearDownAfterClass(); } @@ -146,7 +149,7 @@ class VersioningTest extends \Test\TestCase { $this->assertEquals($sizeOfAllDeletedFiles, $size); // the deleted array should only contain versions which should be deleted - foreach($deleted as $key => $path) { + foreach ($deleted as $key => $path) { unset($versions[$key]); $this->assertEquals("delete", substr($path, 0, strlen("delete"))); } @@ -155,7 +158,6 @@ class VersioningTest extends \Test\TestCase { foreach ($versions as $version) { $this->assertEquals("keep", $version['path']); } - } public function versionsProvider() { @@ -277,7 +279,6 @@ class VersioningTest extends \Test\TestCase { } public function testRename() { - \OC\Files\Filesystem::file_put_contents("test.txt", "test file"); $t1 = time(); @@ -307,7 +308,6 @@ class VersioningTest extends \Test\TestCase { } public function testRenameInSharedFolder() { - \OC\Files\Filesystem::mkdir('folder1'); \OC\Files\Filesystem::mkdir('folder1/folder2'); \OC\Files\Filesystem::file_put_contents("folder1/test.txt", "test file"); @@ -358,7 +358,6 @@ class VersioningTest extends \Test\TestCase { } public function testMoveFolder() { - \OC\Files\Filesystem::mkdir('folder1'); \OC\Files\Filesystem::mkdir('folder2'); \OC\Files\Filesystem::file_put_contents('folder1/test.txt', 'test file'); @@ -392,7 +391,6 @@ class VersioningTest extends \Test\TestCase { public function testMoveFileIntoSharedFolderAsRecipient() { - \OC\Files\Filesystem::mkdir('folder1'); $fileInfo = \OC\Files\Filesystem::getFileInfo('folder1'); @@ -443,7 +441,6 @@ class VersioningTest extends \Test\TestCase { } public function testMoveFolderIntoSharedFolderAsRecipient() { - \OC\Files\Filesystem::mkdir('folder1'); $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); @@ -495,7 +492,6 @@ class VersioningTest extends \Test\TestCase { } public function testRenameSharedFile() { - \OC\Files\Filesystem::file_put_contents("test.txt", "test file"); $t1 = time(); @@ -545,7 +541,6 @@ class VersioningTest extends \Test\TestCase { } public function testCopy() { - \OC\Files\Filesystem::file_put_contents("test.txt", "test file"); $t1 = time(); @@ -579,7 +574,6 @@ class VersioningTest extends \Test\TestCase { * the correct 'path' and 'name' */ public function testGetVersions() { - $t1 = time(); // second version is two weeks older, this way we make sure that no // version will be expired @@ -944,7 +938,6 @@ class VersioningTest extends \Test\TestCase { * @param bool $create */ public static function loginHelper($user, $create = false) { - if ($create) { $backend = new \Test\Util\User\Dummy(); $backend->createUser($user, $user); @@ -964,7 +957,6 @@ class VersioningTest extends \Test\TestCase { \OC_Util::setupFS($user); \OC::$server->getUserFolder($user); } - } // extend the original class to make it possible to test protected methods @@ -975,6 +967,5 @@ class VersionStorageToTest extends \OCA\Files_Versions\Storage { */ public function callProtectedGetExpireList($time, $versions) { return self::getExpireList($time, $versions); - } } |