diff options
-rw-r--r-- | core/js/mimetypelist.js | 97 | ||||
-rw-r--r-- | lib/private/DirectEditing/Token.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Node/File.php | 15 | ||||
-rw-r--r-- | lib/private/Files/Node/Node.php | 23 | ||||
-rw-r--r-- | lib/private/Files/View.php | 24 | ||||
-rw-r--r-- | lib/public/Files/File.php | 13 | ||||
-rw-r--r-- | lib/public/Files/Node.php | 29 | ||||
-rw-r--r-- | tests/acceptance/features/app-files-tags.feature | 6 |
8 files changed, 173 insertions, 36 deletions
diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js index e7aae542a3c..760d503f23e 100644 --- a/core/js/mimetypelist.js +++ b/core/js/mimetypelist.js @@ -7,7 +7,102 @@ * To regenerate this file run ./occ maintenance:mimetype:update-js */ OC.MimeTypeList={ - aliases: [], + aliases: { + "application/coreldraw": "image", + "application/epub+zip": "text", + "application/font-sfnt": "image", + "application/font-woff": "image", + "application/gpx+xml": "location", + "application/illustrator": "image", + "application/javascript": "text/code", + "application/json": "text/code", + "application/msaccess": "file", + "application/msexcel": "x-office/spreadsheet", + "application/msonenote": "x-office/document", + "application/mspowerpoint": "x-office/presentation", + "application/msword": "x-office/document", + "application/octet-stream": "file", + "application/postscript": "image", + "application/rss+xml": "application/xml", + "application/vnd.android.package-archive": "package/x-generic", + "application/vnd.lotus-wordpro": "x-office/document", + "application/vnd.garmin.tcx+xml": "location", + "application/vnd.google-earth.kml+xml": "location", + "application/vnd.google-earth.kmz": "location", + "application/vnd.ms-excel": "x-office/spreadsheet", + "application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet", + "application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet", + "application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet", + "application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet", + "application/vnd.ms-fontobject": "image", + "application/vnd.ms-powerpoint": "x-office/presentation", + "application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation", + "application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation", + "application/vnd.ms-powerpoint.slideshow.macroEnabled.12": "x-office/presentation", + "application/vnd.ms-powerpoint.template.macroEnabled.12": "x-office/presentation", + "application/vnd.ms-visio.drawing.macroEnabled.12": "application/vnd.visio", + "application/vnd.ms-visio.drawing": "application/vnd.visio", + "application/vnd.ms-visio.stencil.macroEnabled.12": "application/vnd.visio", + "application/vnd.ms-visio.stencil": "application/vnd.visio", + "application/vnd.ms-visio.template.macroEnabled.12": "application/vnd.visio", + "application/vnd.ms-visio.template": "application/vnd.visio", + "application/vnd.ms-word.document.macroEnabled.12": "x-office/document", + "application/vnd.ms-word.template.macroEnabled.12": "x-office/document", + "application/vnd.oasis.opendocument.presentation": "x-office/presentation", + "application/vnd.oasis.opendocument.presentation-template": "x-office/presentation", + "application/vnd.oasis.opendocument.spreadsheet": "x-office/spreadsheet", + "application/vnd.oasis.opendocument.spreadsheet-template": "x-office/spreadsheet", + "application/vnd.oasis.opendocument.text": "x-office/document", + "application/vnd.oasis.opendocument.text-master": "x-office/document", + "application/vnd.oasis.opendocument.text-template": "x-office/document", + "application/vnd.oasis.opendocument.text-web": "x-office/document", + "application/vnd.openxmlformats-officedocument.presentationml.presentation": "x-office/presentation", + "application/vnd.openxmlformats-officedocument.presentationml.slideshow": "x-office/presentation", + "application/vnd.openxmlformats-officedocument.presentationml.template": "x-office/presentation", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "x-office/spreadsheet", + "application/vnd.openxmlformats-officedocument.spreadsheetml.template": "x-office/spreadsheet", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document", + "application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document", + "application/vnd.visio": "x-office/document", + "application/vnd.wordperfect": "x-office/document", + "application/x-7z-compressed": "package/x-generic", + "application/x-bzip2": "package/x-generic", + "application/x-cbr": "text", + "application/x-compressed": "package/x-generic", + "application/x-dcraw": "image", + "application/x-deb": "package/x-generic", + "application/x-fictionbook+xml": "text", + "application/x-font": "image", + "application/x-gimp": "image", + "application/x-gzip": "package/x-generic", + "application/x-iwork-keynote-sffkey": "x-office/presentation", + "application/x-iwork-numbers-sffnumbers": "x-office/spreadsheet", + "application/x-iwork-pages-sffpages": "x-office/document", + "application/x-mobipocket-ebook": "text", + "application/x-perl": "text/code", + "application/x-photoshop": "image", + "application/x-php": "text/code", + "application/x-rar-compressed": "package/x-generic", + "application/x-tar": "package/x-generic", + "application/x-tex": "text", + "application/xml": "text/html", + "application/yaml": "text/code", + "application/zip": "package/x-generic", + "database": "file", + "httpd/unix-directory": "dir", + "text/css": "text/code", + "text/csv": "x-office/spreadsheet", + "text/html": "text/code", + "text/x-c": "text/code", + "text/x-c++src": "text/code", + "text/x-h": "text/code", + "text/x-java-source": "text/code", + "text/x-ldif": "text/code", + "text/x-python": "text/code", + "text/x-shellscript": "text/code", + "web": "text/code", + "application/internet-shortcut": "link" +}, files: [ "application", "application-pdf", diff --git a/lib/private/DirectEditing/Token.php b/lib/private/DirectEditing/Token.php index 946699900b7..148621a2cf3 100644 --- a/lib/private/DirectEditing/Token.php +++ b/lib/private/DirectEditing/Token.php @@ -62,7 +62,7 @@ class Token implements IToken { } public function hasBeenAccessed(): bool { - return $this->data['accessed'] === '1'; + return (bool) $this->data['accessed']; } public function getEditor(): string { diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index b504c7a29da..e4669f70709 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -28,6 +28,7 @@ namespace OC\Files\Node; use OCP\Files\GenericFileException; use OCP\Files\NotPermittedException; +use OCP\Lock\LockedException; class File extends Node implements \OCP\Files\File { /** @@ -42,7 +43,8 @@ class File extends Node implements \OCP\Files\File { /** * @return string - * @throws \OCP\Files\NotPermittedException + * @throws NotPermittedException + * @throws LockedException */ public function getContent() { if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { @@ -57,8 +59,9 @@ class File extends Node implements \OCP\Files\File { /** * @param string|resource $data - * @throws \OCP\Files\NotPermittedException + * @throws NotPermittedException * @throws \OCP\Files\GenericFileException + * @throws LockedException */ public function putContent($data) { if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { @@ -76,7 +79,8 @@ class File extends Node implements \OCP\Files\File { /** * @param string $mode * @return resource - * @throws \OCP\Files\NotPermittedException + * @throws NotPermittedException + * @throws LockedException */ public function fopen($mode) { $preHooks = array(); @@ -113,6 +117,11 @@ class File extends Node implements \OCP\Files\File { } } + /** + * @throws NotPermittedException + * @throws \OCP\Files\InvalidPathException + * @throws \OCP\Files\NotFoundException + */ public function delete() { if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { $this->sendHooks(array('preDelete')); diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 95d16cf5c99..7f50524f28d 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -33,6 +33,7 @@ use OCP\Files\FileInfo; use OCP\Files\InvalidPathException; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; +use OCP\Lock\LockedException; use Symfony\Component\EventDispatcher\GenericEvent; // FIXME: this class really should be abstract @@ -75,6 +76,7 @@ class Node implements \OCP\Files\Node { * * @param string $path path * @return string non-existing node class + * @throws \Exception */ protected function createNonExistingNode($path) { throw new \Exception('Must be implemented by subclasses'); @@ -117,6 +119,8 @@ class Node implements \OCP\Files\Node { /** * @param int $permissions * @return bool + * @throws InvalidPathException + * @throws NotFoundException */ protected function checkPermissions($permissions) { return ($this->getPermissions() & $permissions) === $permissions; @@ -127,7 +131,9 @@ class Node implements \OCP\Files\Node { /** * @param int $mtime - * @throws \OCP\Files\NotPermittedException + * @throws InvalidPathException + * @throws NotFoundException + * @throws NotPermittedException */ public function touch($mtime = null) { if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { @@ -366,7 +372,7 @@ class Node implements \OCP\Files\Node { /** * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException */ public function lock($type) { $this->view->lockFile($this->path, $type); @@ -374,7 +380,7 @@ class Node implements \OCP\Files\Node { /** * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException */ public function changeLock($type) { $this->view->changeLock($this->path, $type); @@ -382,7 +388,7 @@ class Node implements \OCP\Files\Node { /** * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException */ public function unlock($type) { $this->view->unlockFile($this->path, $type); @@ -390,8 +396,10 @@ class Node implements \OCP\Files\Node { /** * @param string $targetPath - * @throws \OCP\Files\NotPermittedException if copy not allowed or failed * @return \OC\Files\Node\Node + * @throws InvalidPathException + * @throws NotFoundException + * @throws NotPermittedException if copy not allowed or failed */ public function copy($targetPath) { $targetPath = $this->normalizePath($targetPath); @@ -414,8 +422,11 @@ class Node implements \OCP\Files\Node { /** * @param string $targetPath - * @throws \OCP\Files\NotPermittedException if move not allowed or failed * @return \OC\Files\Node\Node + * @throws InvalidPathException + * @throws NotFoundException + * @throws NotPermittedException if move not allowed or failed + * @throws LockedException */ public function move($targetPath) { $targetPath = $this->normalizePath($targetPath); diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 4f4c4b90f2c..ed962bde1a4 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -589,6 +589,7 @@ class View { /** * @param string $path * @return mixed + * @throws LockedException */ public function file_get_contents($path) { return $this->basicOperation('file_get_contents', $path, array('read')); @@ -640,7 +641,7 @@ class View { * @param string $path * @param string|resource $data * @return bool|mixed - * @throws \Exception + * @throws LockedException */ public function file_put_contents($path, $data) { if (is_resource($data)) { //not having to deal with streams in file_put_contents makes life easier @@ -739,6 +740,7 @@ class View { * @param string $path2 target path * * @return bool|mixed + * @throws LockedException */ public function rename($path1, $path2) { $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); @@ -962,6 +964,7 @@ class View { * @param string $path * @param string $mode 'r' or 'w' * @return resource + * @throws LockedException */ public function fopen($path, $mode) { $mode = str_replace('b', '', $mode); // the binary flag is a windows only feature which we do not support @@ -1117,7 +1120,7 @@ class View { * @param array $hooks (optional) * @param mixed $extraParam (optional) * @return mixed - * @throws \Exception + * @throws LockedException * * This method takes requests for basic filesystem functions (e.g. reading & writing * files), processes hooks and proxies, sanitises paths, and finally passes them on to @@ -1919,7 +1922,7 @@ class View { * @param bool $lockMountPoint true to lock the mount point, false to lock the attached mount/storage * * @return bool False if the path is excluded from locking, true otherwise - * @throws \OCP\Lock\LockedException if the path is already locked + * @throws LockedException if the path is already locked */ private function lockPath($path, $type, $lockMountPoint = false) { $absolutePath = $this->getAbsolutePath($path); @@ -1939,9 +1942,9 @@ class View { $this->lockingProvider ); } - } catch (\OCP\Lock\LockedException $e) { + } catch (LockedException $e) { // rethrow with the a human-readable path - throw new \OCP\Lock\LockedException( + throw new LockedException( $this->getPathRelativeToFiles($absolutePath), $e ); @@ -1959,7 +1962,7 @@ class View { * @param bool $lockMountPoint true to lock the mount point, false to lock the attached mount/storage * * @return bool False if the path is excluded from locking, true otherwise - * @throws \OCP\Lock\LockedException if the path is already locked + * @throws LockedException if the path is already locked */ public function changeLock($path, $type, $lockMountPoint = false) { $path = Filesystem::normalizePath($path); @@ -1980,15 +1983,15 @@ class View { $this->lockingProvider ); } - } catch (\OCP\Lock\LockedException $e) { + } catch (LockedException $e) { try { // rethrow with the a human-readable path - throw new \OCP\Lock\LockedException( + throw new LockedException( $this->getPathRelativeToFiles($absolutePath), $e ); } catch (\InvalidArgumentException $e) { - throw new \OCP\Lock\LockedException( + throw new LockedException( $absolutePath, $e ); @@ -2007,6 +2010,7 @@ class View { * @param bool $lockMountPoint true to lock the mount point, false to lock the attached mount/storage * * @return bool False if the path is excluded from locking, true otherwise + * @throws LockedException */ private function unlockPath($path, $type, $lockMountPoint = false) { $absolutePath = $this->getAbsolutePath($path); @@ -2038,6 +2042,7 @@ class View { * @param bool $lockMountPoint true to lock the mount point, false to lock the attached mount/storage * * @return bool False if the path is excluded from locking, true otherwise + * @throws LockedException */ public function lockFile($path, $type, $lockMountPoint = false) { $absolutePath = $this->getAbsolutePath($path); @@ -2064,6 +2069,7 @@ class View { * @param bool $lockMountPoint true to lock the mount point, false to lock the attached mount/storage * * @return bool False if the path is excluded from locking, true otherwise + * @throws LockedException */ public function unlockFile($path, $type, $lockMountPoint = false) { $absolutePath = $this->getAbsolutePath($path); diff --git a/lib/public/Files/File.php b/lib/public/Files/File.php index 1fe01cfb29a..bd3b3da0df2 100644 --- a/lib/public/Files/File.php +++ b/lib/public/Files/File.php @@ -33,6 +33,8 @@ namespace OCP\Files; +use OCP\Lock\LockedException; + /** * Interface File * @@ -44,7 +46,8 @@ interface File extends Node { * Get the content of the file as string * * @return string - * @throws \OCP\Files\NotPermittedException + * @throws NotPermittedException + * @throws LockedException * @since 6.0.0 */ public function getContent(); @@ -53,8 +56,9 @@ interface File extends Node { * Write to the file from string data * * @param string|resource $data - * @throws \OCP\Files\NotPermittedException - * @throws \OCP\Files\GenericFileException + * @throws NotPermittedException + * @throws GenericFileException + * @throws LockedException * @since 6.0.0 */ public function putContent($data); @@ -72,7 +76,8 @@ interface File extends Node { * * @param string $mode * @return resource - * @throws \OCP\Files\NotPermittedException + * @throws NotPermittedException + * @throws LockedException * @since 6.0.0 */ public function fopen($mode); diff --git a/lib/public/Files/Node.php b/lib/public/Files/Node.php index 4468b680014..af7d9454ca6 100644 --- a/lib/public/Files/Node.php +++ b/lib/public/Files/Node.php @@ -34,6 +34,8 @@ namespace OCP\Files; +use OCP\Lock\LockedException; + /** * Interface Node * @@ -45,15 +47,22 @@ interface Node extends FileInfo { * Move the file or folder to a new location * * @param string $targetPath the absolute target path - * @throws \OCP\Files\NotPermittedException - * @return \OCP\Files\Node + * @return Node + * @throws NotFoundException + * @throws NotPermittedException if move not allowed or failed + * @throws LockedException + * @throws InvalidPathException * @since 6.0.0 */ public function move($targetPath); /** * Delete the file or folder + * * @return void + * @throws NotPermittedException + * @throws InvalidPathException + * @throws NotFoundException * @since 6.0.0 */ public function delete(); @@ -62,7 +71,7 @@ interface Node extends FileInfo { * Cope the file or folder to a new location * * @param string $targetPath the absolute target path - * @return \OCP\Files\Node + * @return Node * @since 6.0.0 */ public function copy($targetPath); @@ -72,7 +81,9 @@ interface Node extends FileInfo { * If $mtime is omitted the current time will be used * * @param int $mtime (optional) modified date as unix timestamp - * @throws \OCP\Files\NotPermittedException + * @throws InvalidPathException + * @throws NotFoundException + * @throws NotPermittedException * @return void * @since 6.0.0 */ @@ -81,8 +92,8 @@ interface Node extends FileInfo { /** * Get the storage backend the file or folder is stored on * - * @return \OCP\Files\Storage - * @throws \OCP\Files\NotFoundException + * @return Storage + * @throws NotFoundException * @since 6.0.0 */ public function getStorage(); @@ -247,7 +258,7 @@ interface Node extends FileInfo { * any filesystem operation will automatically acquire the relevant locks for that operation. * * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException * @since 9.1.0 */ public function lock($type); @@ -262,7 +273,7 @@ interface Node extends FileInfo { * Note that this is also the case if no existing lock exists for the file. * * @param int $targetType \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException * @since 9.1.0 */ public function changeLock($targetType); @@ -275,7 +286,7 @@ interface Node extends FileInfo { * Note that this method will not give any sort of error when trying to free a lock that doesn't exist. * * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException * @since 9.1.0 */ public function unlock($type); diff --git a/tests/acceptance/features/app-files-tags.feature b/tests/acceptance/features/app-files-tags.feature index 093ae371912..8514a59d7d0 100644 --- a/tests/acceptance/features/app-files-tags.feature +++ b/tests/acceptance/features/app-files-tags.feature @@ -22,7 +22,7 @@ Feature: app-files-tags Scenario: create tags using the Administration settings Given I am logged in as the admin And I visit the settings page - And I open the "Workflows" section of the "Administration" group + And I open the "Basic settings" section of the "Administration" group # The "create" button does nothing before JavaScript was initialized, and # the only way to detect that is waiting for the button to select tags to be # shown. @@ -33,7 +33,7 @@ Feature: app-files-tags # Scenario: add tags using the dropdown in the details view # Given I am logged in as the admin # And I visit the settings page -# And I open the "Workflows" section of the "Administration" group +# And I open the "Basic settings" section of the "Administration" group # # The "create" button does nothing before JavaScript was initialized, and # # the only way to detect that is waiting for the button to select tags to be # # shown. @@ -61,7 +61,7 @@ Feature: app-files-tags # Scenario: remove tags using the dropdown in the details view # Given I am logged in as the admin # And I visit the settings page -# And I open the "Workflows" section of the "Administration" group +# And I open the "Basic settings" section of the "Administration" group # # The "create" button does nothing before JavaScript was initialized, and # # the only way to detect that is waiting for the button to select tags to be # # shown. |