Skip non-supported mimes

This commit is contained in:
Victor Dubiniuk 2015-01-23 18:34:58 +03:00
parent 9aa4275508
commit e24b01bdd6
3 changed files with 24 additions and 9 deletions

View File

@ -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());

View File

@ -61,5 +61,14 @@ namespace OCA\Documents;
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());
} }
}

View File

@ -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()