mirror of https://github.com/MISP/MISP
fix: [internal] Fix of wonky model function calls across the application for getting default attachment directories
parent
53cf70a415
commit
c96be93e3c
|
@ -2770,8 +2770,7 @@ class EventsController extends AppController
|
|||
// write
|
||||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$this->loadModel('Server');
|
||||
$attachments_dir = $this->Server->getDefaultAttachments_dir();
|
||||
$attachments_dir = $this->Event->getDefaultAttachments_dir();
|
||||
}
|
||||
$rootDir = $attachments_dir . DS . $id . DS;
|
||||
App::uses('Folder', 'Utility');
|
||||
|
|
|
@ -201,8 +201,7 @@ class ShadowAttributesController extends AppController
|
|||
{
|
||||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
$attachments_dir = $this->ShadowAttribute->getDefaultAttachments_dir();
|
||||
}
|
||||
$pathOld = $attachments_dir . DS . 'shadow' . DS . $shadowId;
|
||||
$pathNew = $attachments_dir . DS . $newId;
|
||||
|
@ -506,8 +505,7 @@ class ShadowAttributesController extends AppController
|
|||
{
|
||||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
$attachments_dir = $this->ShadowAttribute->getDefaultAttachments_dir();
|
||||
}
|
||||
$path = $attachments_dir . DS . 'shadow' . DS . $shadowAttribute['event_id'] . DS;
|
||||
$file = $shadowAttribute['id'];
|
||||
|
|
|
@ -1793,4 +1793,14 @@ class AppModel extends Model
|
|||
}
|
||||
return $val / (1024 * 1024);
|
||||
}
|
||||
|
||||
public function getDefaultAttachments_dir()
|
||||
{
|
||||
return APP . 'files';
|
||||
}
|
||||
|
||||
public function getDefaultTmp_dir()
|
||||
{
|
||||
return sys_get_temp_dir();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -675,8 +675,7 @@ class Attribute extends AppModel
|
|||
// only delete the file if it exists
|
||||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
$attachments_dir = $this->getDefaultAttachments_dir();
|
||||
}
|
||||
|
||||
// Special case - If using S3, we have to delete from there
|
||||
|
@ -1531,8 +1530,7 @@ class Attribute extends AppModel
|
|||
{
|
||||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
$attachments_dir = $this->getDefaultAttachments_dir();
|
||||
}
|
||||
|
||||
if ($this->attachmentDirIsS3()) {
|
||||
|
@ -1557,8 +1555,7 @@ class Attribute extends AppModel
|
|||
{
|
||||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
$attachments_dir = $this->getDefaultAttachments_dir();
|
||||
}
|
||||
|
||||
if ($this->attachmentDirIsS3()) {
|
||||
|
@ -2993,8 +2990,7 @@ class Attribute extends AppModel
|
|||
}
|
||||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
$attachments_dir = $this->getDefaultAttachments_dir();
|
||||
}
|
||||
|
||||
// If we've set attachments to S3, we can't write there
|
||||
|
@ -3003,8 +2999,7 @@ class Attribute extends AppModel
|
|||
// Sometimes it's not set?
|
||||
if (empty($attachments_dir)) {
|
||||
// Get a default tmpdir
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->getDefaultTmp_dir();
|
||||
$attachments_dir = $this->getDefaultTmp_dir();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2051,7 +2051,7 @@ class Server extends AppModel
|
|||
'action' => 'pull',
|
||||
'user_id' => $user['id'],
|
||||
'title' => 'Failed to pull event #' . $eventid . '.',
|
||||
'change' => 'Reason:' . $message
|
||||
'change' => 'Reason:' . $message
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -4142,16 +4142,6 @@ class Server extends AppModel
|
|||
return $final;
|
||||
}
|
||||
|
||||
public function getDefaultAttachments_dir()
|
||||
{
|
||||
return APP . 'files';
|
||||
}
|
||||
|
||||
public function getDefaultTmp_dir()
|
||||
{
|
||||
return sys_get_temp_dir();
|
||||
}
|
||||
|
||||
public function fetchServer($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
|
|
Loading…
Reference in New Issue