Skip non-supported mimes
This commit is contained in:
parent
9aa4275508
commit
e24b01bdd6
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace OCA\Documents\Db;
|
namespace OCA\Documents\Db;
|
||||||
|
|
||||||
|
use OCA\Documents\Filter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session management
|
* Session management
|
||||||
*
|
*
|
||||||
@ -47,6 +49,10 @@ class Session extends \OCA\Documents\Db {
|
|||||||
$genesis = new \OCA\Documents\Genesis($file);
|
$genesis = new \OCA\Documents\Genesis($file);
|
||||||
|
|
||||||
list($ownerView, $path) = $file->getOwnerViewAndPath();
|
list($ownerView, $path) = $file->getOwnerViewAndPath();
|
||||||
|
$mimetype = $ownerView->getMimeType($path);
|
||||||
|
if (!Filter::isSupportedMimetype($mimetype)){
|
||||||
|
throw new \Exception( $path . ' is ' . $mimetype . ' and is not supported by Documents app');
|
||||||
|
}
|
||||||
$oldSession = new Session();
|
$oldSession = new Session();
|
||||||
$oldSession->loadBy('file_id', $file->getFileId());
|
$oldSession->loadBy('file_id', $file->getFileId());
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
namespace OCA\Documents;
|
namespace OCA\Documents;
|
||||||
|
|
||||||
class Filter {
|
class Filter {
|
||||||
protected static $filters = array();
|
protected static $filters = array();
|
||||||
|
|
||||||
public static function add($mimetype, $class){
|
public static function add($mimetype, $class){
|
||||||
self::$filters[$mimetype] = $class;
|
self::$filters[$mimetype] = $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,9 +36,9 @@ namespace OCA\Documents;
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function write($content, $mimetype){
|
public static function write($content, $mimetype){
|
||||||
$data = array(
|
$data = array(
|
||||||
'mimetype' => $mimetype,
|
'mimetype' => $mimetype,
|
||||||
'content' => $content
|
'content' => $content
|
||||||
@ -55,11 +55,20 @@ namespace OCA\Documents;
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAll(){
|
public static function getAll(){
|
||||||
return array_keys(self::$filters);
|
return array_keys(self::$filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if mimetype is supported by the app
|
||||||
|
* @param string $mimetype - checked mimetype
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isSupportedMimetype($mimetype){
|
||||||
|
return in_array($mimetype, Storage::getSupportedMimetypes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -97,7 +97,7 @@ class Storage {
|
|||||||
return $documents;
|
return $documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function getSupportedMimetypes(){
|
public static function getSupportedMimetypes(){
|
||||||
return array_merge(
|
return array_merge(
|
||||||
array(self::MIMETYPE_LIBREOFFICE_WORDPROCESSOR),
|
array(self::MIMETYPE_LIBREOFFICE_WORDPROCESSOR),
|
||||||
Filter::getAll()
|
Filter::getAll()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user