diff options
-rw-r--r-- | apps/files/js/file-upload.js | 16 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 19 | ||||
-rw-r--r-- | apps/files/lib/app.php | 23 | ||||
-rw-r--r-- | apps/files/templates/index.php | 4 | ||||
-rw-r--r-- | apps/files/tests/ajax_rename.php | 63 | ||||
-rw-r--r-- | apps/files_encryption/ajax/getMigrationStatus.php | 9 | ||||
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 4 | ||||
-rw-r--r-- | core/js/share.js | 2 | ||||
-rw-r--r-- | lib/private/db/mdb2schemamanager.php | 2 | ||||
-rw-r--r-- | lib/private/files/cache/updater.php | 6 | ||||
-rw-r--r-- | tests/lib/files/cache/updater.php | 8 | ||||
-rw-r--r-- | version.php | 4 |
12 files changed, 120 insertions, 40 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index bc1244a1e6e..e9663353f74 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -508,11 +508,15 @@ $(document).ready(function() { $(this).children('p').remove(); // add input field - var form=$('<form></form>'); - var input=$('<input type="text">'); + var form = $('<form></form>'); + var input = $('<input type="text">'); + var newName = $(this).attr('data-newname') || ''; + if (newName) { + input.val(newName); + } form.append(input); $(this).append(form); - + var lastPos; var checkInput = function () { var filename = input.val(); if (type === 'web' && filename.length === 0) { @@ -543,6 +547,12 @@ $(document).ready(function() { }); input.focus(); + // pre select name up to the extension + lastPos = newName.lastIndexOf('.'); + if (lastPos === -1) { + lastPos = newName.length; + } + input.selectRange(0, lastPos); form.submit(function(event) { event.stopPropagation(); event.preventDefault(); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 66453740f5d..b8ae00ac494 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -422,12 +422,27 @@ var FileList={ } tr.find('.fileactions').effect('highlight', {}, 5000); tr.effect('highlight', {}, 5000); + // remove loading mark and recover old image + td.css('background-image', oldBackgroundImage); + } + else { + var fileInfo = result.data; + tr.attr('data-mime', fileInfo.mime); + tr.attr('data-etag', fileInfo.etag); + if (fileInfo.isPreviewAvailable) { + Files.lazyLoadPreview(fileInfo.directory + '/' + fileInfo.name, result.data.mime, function(previewpath) { + tr.find('td.filename').attr('style','background-image:url('+previewpath+')'); + }, null, null, result.data.etag); + } + else { + tr.find('td.filename').removeClass('preview').attr('style','background-image:url('+fileInfo.icon+')'); + } } // reinsert row tr.detach(); FileList.insertElement( tr.attr('data-file'), tr.attr('data-type'),tr ); - // remove loading mark and recover old image - td.css('background-image', oldBackgroundImage); + // update file actions in case the extension changed + FileActions.display( tr.find('td.filename'), true); } }); } diff --git a/apps/files/lib/app.php b/apps/files/lib/app.php index f5ac11b2168..e04ac173d55 100644 --- a/apps/files/lib/app.php +++ b/apps/files/lib/app.php @@ -76,12 +76,25 @@ class App { $this->view->rename($dir . '/' . $oldname, $dir . '/' . $newname) ) { // successful rename - $result['success'] = true; - $result['data'] = array( - 'dir' => $dir, - 'file' => $oldname, - 'newname' => $newname + $meta = $this->view->getFileInfo($dir . '/' . $newname); + if ($meta['mimetype'] === 'httpd/unix-directory') { + $meta['type'] = 'dir'; + } + else { + $meta['type'] = 'file'; + } + $fileinfo = array( + 'id' => $meta['fileid'], + 'mime' => $meta['mimetype'], + 'size' => $meta['size'], + 'etag' => $meta['etag'], + 'directory' => $dir, + 'name' => $newname, + 'isPreviewAvailable' => \OC::$server->getPreviewManager()->isMimeSupported($meta['mimetype']), + 'icon' => \OCA\Files\Helper::determineIcon($meta) ); + $result['success'] = true; + $result['data'] = $fileinfo; } else { // rename failed $result['data'] = array( diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 4f8623573cb..99d66ed3f9c 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -5,9 +5,9 @@ <a><?php p($l->t('New'));?></a> <ul> <li style="background-image:url('<?php p(OCP\mimetype_icon('text/plain')) ?>')" - data-type='file'><p><?php p($l->t('Text file'));?></p></li> + data-type='file' data-newname='<?php p($l->t('New text file')) ?>.txt'><p><?php p($l->t('Text file'));?></p></li> <li style="background-image:url('<?php p(OCP\mimetype_icon('dir')) ?>')" - data-type='folder'><p><?php p($l->t('Folder'));?></p></li> + data-type='folder' data-newname='<?php p($l->t('New folder')) ?>'><p><?php p($l->t('Folder'));?></p></li> <li style="background-image:url('<?php p(OCP\image_path('core', 'places/link.svg')) ?>')" data-type='web'><p><?php p($l->t('From link'));?></p></li> </ul> diff --git a/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php index 3735b0a49c8..350ff5d3687 100644 --- a/apps/files/tests/ajax_rename.php +++ b/apps/files/tests/ajax_rename.php @@ -38,13 +38,14 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase { $l10nMock->expects($this->any()) ->method('t') ->will($this->returnArgument(0)); - $viewMock = $this->getMock('\OC\Files\View', array('rename', 'normalizePath'), array(), '', false); + $viewMock = $this->getMock('\OC\Files\View', array('rename', 'normalizePath', 'getFileInfo'), array(), '', false); $viewMock->expects($this->any()) ->method('normalizePath') ->will($this->returnArgument(0)); $viewMock->expects($this->any()) ->method('rename') ->will($this->returnValue(true)); + $this->viewMock = $viewMock; $this->files = new \OCA\Files\App($viewMock, $l10nMock); } @@ -79,17 +80,28 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase { $oldname = 'Shared'; $newname = 'new_name'; + $this->viewMock->expects($this->any()) + ->method('getFileInfo') + ->will($this->returnValue(array( + 'fileid' => 123, + 'type' => 'dir', + 'mimetype' => 'httpd/unix-directory', + 'size' => 18, + 'etag' => 'abcdef', + 'directory' => '/', + 'name' => 'new_name', + ))); + $result = $this->files->rename($dir, $oldname, $newname); - $expected = array( - 'success' => true, - 'data' => array( - 'dir' => $dir, - 'file' => $oldname, - 'newname' => $newname - ) - ); - $this->assertEquals($expected, $result); + $this->assertTrue($result['success']); + $this->assertEquals(123, $result['data']['id']); + $this->assertEquals('new_name', $result['data']['name']); + $this->assertEquals('/test', $result['data']['directory']); + $this->assertEquals(18, $result['data']['size']); + $this->assertEquals('httpd/unix-directory', $result['data']['mime']); + $this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']); + $this->assertFalse($result['data']['isPreviewAvailable']); } /** @@ -117,16 +129,29 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase { $oldname = 'oldname'; $newname = 'newname'; + $this->viewMock->expects($this->any()) + ->method('getFileInfo') + ->will($this->returnValue(array( + 'fileid' => 123, + 'type' => 'dir', + 'mimetype' => 'httpd/unix-directory', + 'size' => 18, + 'etag' => 'abcdef', + 'directory' => '/', + 'name' => 'new_name', + ))); + + $result = $this->files->rename($dir, $oldname, $newname); - $expected = array( - 'success' => true, - 'data' => array( - 'dir' => $dir, - 'file' => $oldname, - 'newname' => $newname - ) - ); - $this->assertEquals($expected, $result); + $this->assertTrue($result['success']); + $this->assertEquals(123, $result['data']['id']); + $this->assertEquals('newname', $result['data']['name']); + $this->assertEquals('/', $result['data']['directory']); + $this->assertEquals(18, $result['data']['size']); + $this->assertEquals('httpd/unix-directory', $result['data']['mime']); + $this->assertEquals('abcdef', $result['data']['etag']); + $this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']); + $this->assertFalse($result['data']['isPreviewAvailable']); } } diff --git a/apps/files_encryption/ajax/getMigrationStatus.php b/apps/files_encryption/ajax/getMigrationStatus.php index 4da035a97d4..17469a1af0c 100644 --- a/apps/files_encryption/ajax/getMigrationStatus.php +++ b/apps/files_encryption/ajax/getMigrationStatus.php @@ -10,14 +10,15 @@ use OCA\Encryption\Util; \OCP\JSON::checkAppEnabled('files_encryption'); -$user = isset($_POST['user']) ? $_POST['user'] : ''; +$loginname = isset($_POST['user']) ? $_POST['user'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; $migrationCompleted = true; -if ($user !== '' && $password !== '') { - if (\OCP\User::checkPassword($user, $password)) { - $util = new Util(new \OC_FilesystemView('/'), $user); +if ($loginname !== '' && $password !== '') { + $username = \OCP\User::checkPassword($loginname, $password); + if ($username) { + $util = new Util(new \OC_FilesystemView('/'), $username); if ($util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) { $migrationCompleted = false; } diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index 35574b8e5b9..f142f525cfa 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -318,8 +318,8 @@ class Hooks { // get the parent from current share
$parent = $util->getShareParent($params['parent']);
- // if parent is file the it is an 1:1 share
- if ($parent['item_type'] === 'file') {
+ // if parent has the same type than the child it is a 1:1 share
+ if ($parent['item_type'] === $params['itemType']) {
// prefix path with Shared
$path = '/Shared' . $parent['file_target'];
diff --git a/core/js/share.js b/core/js/share.js index e2911ae2ff3..10ab5f47f27 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -461,7 +461,7 @@ OC.Share={ if (password != null) { $('#linkPass').show('blind'); $('#showPassword').attr('checked', true); - $('#linkPassText').attr('placeholder', t('core', 'Password protected')); + $('#linkPassText').attr('placeholder', '**********'); } $('#expiration').show(); $('#emailPrivateLink #email').show(); diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php index 416e2f55426..6378c769055 100644 --- a/lib/private/db/mdb2schemamanager.php +++ b/lib/private/db/mdb2schemamanager.php @@ -19,6 +19,8 @@ class MDB2SchemaManager { */ public function __construct($conn) { $this->conn = $conn; + $this->conn->close(); + $this->conn->connect(); } /** diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index d45c5e17fc8..9ef147aa157 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -86,6 +86,12 @@ class Updater { if ($storageFrom === $storageTo) { $cache = $storageFrom->getCache($internalFrom); $cache->move($internalFrom, $internalTo); + if (pathinfo($internalFrom, PATHINFO_EXTENSION) !== pathinfo($internalTo, PATHINFO_EXTENSION)) { + // redetect mime type change + $mimeType = $storageTo->getMimeType($internalTo); + $fileId = $storageTo->getCache()->getId($internalTo); + $storageTo->getCache()->update($fileId, array('mimetype' => $mimeType)); + } $cache->correctFolderSize($internalFrom); $cache->correctFolderSize($internalTo); self::correctFolder($from, time()); diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php index e3d3aae818d..91e384e12af 100644 --- a/tests/lib/files/cache/updater.php +++ b/tests/lib/files/cache/updater.php @@ -202,6 +202,14 @@ class Updater extends \PHPUnit_Framework_TestCase { $this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']); } + public function testRenameExtension() { + $fooCachedData = $this->cache->get('foo.txt'); + $this->assertEquals('text/plain', $fooCachedData['mimetype']); + Filesystem::rename('foo.txt', 'foo.abcd'); + $fooCachedData = $this->cache->get('foo.abcd'); + $this->assertEquals('application/octet-stream', $fooCachedData['mimetype']); + } + public function testRenameWithMountPoints() { $storage2 = new \OC\Files\Storage\Temporary(array()); $cache2 = $storage2->getCache(); diff --git a/version.php b/version.php index 2e3b8f1f904..e694eb188bb 100644 --- a/version.php +++ b/version.php @@ -1,10 +1,10 @@ <?php // We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel when updating major/minor version number. -$OC_Version=array(6, 00, 0, 8); +$OC_Version=array(6, 00, 0, 9); // The human readable string -$OC_VersionString='6.0 beta 5'; +$OC_VersionString='6.0 RC1'; // The ownCloud edition $OC_Edition=''; |