summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-04-08 17:17:48 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-04-23 12:54:25 +0200
commit27c5a978f91e7aa447a2acca040fd173baba53b9 (patch)
tree462029db1f2b24055f82967f1e5cf4e5736f9d2c /apps
parent83d68107253834aa5322198295c827d94e951e90 (diff)
downloadnextcloud-server-27c5a978f91e7aa447a2acca040fd173baba53b9.tar.gz
nextcloud-server-27c5a978f91e7aa447a2acca040fd173baba53b9.zip
we no longer need to handle the Shared folder different from any other folder
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/file-upload.js4
-rw-r--r--apps/files/js/fileactions.js8
-rw-r--r--apps/files/js/filelist.js2
-rw-r--r--apps/files/js/files.js6
-rw-r--r--apps/files/lib/app.php11
-rw-r--r--apps/files/tests/ajax_rename.php82
-rw-r--r--apps/files/tests/js/filesSpec.js35
7 files changed, 8 insertions, 140 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 3879aa65888..03ebdccb32d 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -235,7 +235,7 @@ OC.Upload = {
var file = data.files[0];
try {
// FIXME: not so elegant... need to refactor that method to return a value
- Files.isFileNameValid(file.name, FileList.getCurrentDirectory());
+ Files.isFileNameValid(file.name);
}
catch (errorMessage) {
data.textStatus = 'invalidcharacters';
@@ -555,8 +555,6 @@ OC.Upload = {
throw t('files', 'URL cannot be empty');
} else if (type !== 'web' && !Files.isFileNameValid(filename)) {
// Files.isFileNameValid(filename) throws an exception itself
- } else if (FileList.getCurrentDirectory() === '/' && filename.toLowerCase() === 'shared') {
- throw t('files', 'In the home folder \'Shared\' is a reserved filename');
} else if (FileList.inList(filename)) {
throw t('files', '{new_name} already exists', {new_name: filename});
} else {
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 631aebea954..ecdfa72a477 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -118,10 +118,6 @@ var FileActions = {
};
var addAction = function (name, action, displayName) {
- // NOTE: Temporary fix to prevent rename action in root of Shared directory
- if (name === 'Rename' && $('#dir').val() === '/Shared') {
- return true;
- }
if ((name === 'Download' || action !== defaultAction) && name !== 'Delete') {
@@ -160,7 +156,7 @@ var FileActions = {
addAction(name, ah, displayName);
}
});
- if(actions.Share && !($('#dir').val() === '/' && file === 'Shared')){
+ if(actions.Share){
displayName = t('files', 'Share');
addAction('Share', actions.Share, displayName);
}
@@ -223,7 +219,7 @@ $(document).ready(function () {
$('#fileList tr').each(function () {
FileActions.display($(this).children('td.filename'));
});
-
+
$('#fileList').trigger(jQuery.Event("fileActionsReady"));
});
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 9c749bb8f34..343da217416 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -580,7 +580,7 @@ window.FileList = {
var filename = input.val();
if (filename !== oldname) {
// Files.isFileNameValid(filename) throws an exception itself
- Files.isFileNameValid(filename, FileList.getCurrentDirectory());
+ Files.isFileNameValid(filename);
if (FileList.inList(filename)) {
throw t('files', '{new_name} already exists', {new_name: filename});
}
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 9f38263bef3..5e669a796a9 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -87,11 +87,9 @@ var Files = {
* Throws a string exception with an error message if
* the file name is not valid
*/
- isFileNameValid: function (name, root) {
+ isFileNameValid: function (name) {
var trimmedName = name.trim();
- if (trimmedName === '.'
- || trimmedName === '..'
- || (root === '/' && trimmedName.toLowerCase() === 'shared'))
+ if (trimmedName === '.' || trimmedName === '..')
{
throw t('files', '"{name}" is an invalid file name.', {name: name});
} else if (trimmedName.length === 0) {
diff --git a/apps/files/lib/app.php b/apps/files/lib/app.php
index adfca669577..ed4aa32c662 100644
--- a/apps/files/lib/app.php
+++ b/apps/files/lib/app.php
@@ -54,13 +54,8 @@ class App {
'data' => NULL
);
- // rename to "/Shared" is denied
- if( $dir === '/' and $newname === 'Shared' ) {
- $result['data'] = array(
- 'message' => $this->l10n->t("Invalid folder name. Usage of 'Shared' is reserved.")
- );
// rename to non-existing folder is denied
- } else if (!$this->view->file_exists($dir)) {
+ if (!$this->view->file_exists($dir)) {
$result['data'] = array('message' => (string)$this->l10n->t(
'The target folder has been moved or deleted.',
array($dir)),
@@ -68,7 +63,7 @@ class App {
);
// rename to existing file is denied
} else if ($this->view->file_exists($dir . '/' . $newname)) {
-
+
$result['data'] = array(
'message' => $this->l10n->t(
"The name %s is already used in the folder %s. Please choose a different name.",
@@ -77,8 +72,6 @@ class App {
} else if (
// rename to "." is denied
$newname !== '.' and
- // rename of "/Shared" is denied
- !($dir === '/' and $oldname === 'Shared') and
// THEN try to rename
$this->view->rename($dir . '/' . $oldname, $dir . '/' . $newname)
) {
diff --git a/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php
index cb62d22a7e2..74ca1e4495d 100644
--- a/apps/files/tests/ajax_rename.php
+++ b/apps/files/tests/ajax_rename.php
@@ -56,88 +56,6 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
}
/**
- * @brief test rename of file/folder named "Shared"
- */
- function testRenameSharedFolder() {
- $dir = '/';
- $oldname = 'Shared';
- $newname = 'new_name';
-
- $this->viewMock->expects($this->at(0))
- ->method('file_exists')
- ->with('/')
- ->will($this->returnValue(true));
-
- $result = $this->files->rename($dir, $oldname, $newname);
- $expected = array(
- 'success' => false,
- 'data' => array('message' => '%s could not be renamed')
- );
-
- $this->assertEquals($expected, $result);
- }
-
- /**
- * @brief test rename of file/folder named "Shared"
- */
- function testRenameSharedFolderInSubdirectory() {
- $dir = '/test';
- $oldname = 'Shared';
- $newname = 'new_name';
-
- $this->viewMock->expects($this->at(0))
- ->method('file_exists')
- ->with('/test')
- ->will($this->returnValue(true));
-
- $this->viewMock->expects($this->any())
- ->method('getFileInfo')
- ->will($this->returnValue(new \OC\Files\FileInfo(
- '/test',
- null,
- '/test',
- array(
- 'fileid' => 123,
- 'type' => 'dir',
- 'mimetype' => 'httpd/unix-directory',
- 'mtime' => 0,
- 'permissions' => 31,
- 'size' => 18,
- 'etag' => 'abcdef',
- 'directory' => '/',
- 'name' => 'new_name',
- ))));
-
- $result = $this->files->rename($dir, $oldname, $newname);
-
- $this->assertTrue($result['success']);
- $this->assertEquals(123, $result['data']['id']);
- $this->assertEquals('new_name', $result['data']['name']);
- $this->assertEquals(18, $result['data']['size']);
- $this->assertEquals('httpd/unix-directory', $result['data']['mimetype']);
- $icon = \OC_Helper::mimetypeIcon('dir');
- $icon = substr($icon, 0, -3) . 'svg';
- $this->assertEquals($icon, $result['data']['icon']);
- }
-
- /**
- * @brief test rename of file/folder to "Shared"
- */
- function testRenameFolderToShared() {
- $dir = '/';
- $oldname = 'oldname';
- $newname = 'Shared';
-
- $result = $this->files->rename($dir, $oldname, $newname);
- $expected = array(
- 'success' => false,
- 'data' => array('message' => "Invalid folder name. Usage of 'Shared' is reserved.")
- );
-
- $this->assertEquals($expected, $result);
- }
-
- /**
* @brief test rename of file/folder
*/
function testRenameFolder() {
diff --git a/apps/files/tests/js/filesSpec.js b/apps/files/tests/js/filesSpec.js
index 95bf87e03ec..018c8ef0f3c 100644
--- a/apps/files/tests/js/filesSpec.js
+++ b/apps/files/tests/js/filesSpec.js
@@ -48,41 +48,6 @@ describe('Files tests', function() {
expect(error).toEqual(false);
}
});
- it('Validates correct file names do not create Shared folder in root', function() {
- // create shared file in subfolder
- var error = false;
- try {
- expect(Files.isFileNameValid('shared', '/foo')).toEqual(true);
- expect(Files.isFileNameValid('Shared', '/foo')).toEqual(true);
- }
- catch (e) {
- error = e;
- }
- expect(error).toEqual(false);
-
- // create shared file in root
- var threwException = false;
- try {
- Files.isFileNameValid('Shared', '/');
- console.error('Invalid file name not detected');
- }
- catch (e) {
- threwException = true;
- }
- expect(threwException).toEqual(true);
-
- // create shared file in root
- var threwException = false;
- try {
- Files.isFileNameValid('shared', '/');
- console.error('Invalid file name not detected');
- }
- catch (e) {
- threwException = true;
- }
- expect(threwException).toEqual(true);
-
- });
it('Detects invalid file names', function() {
var fileNames = [
'',