mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-06-06 14:46:27 +02:00
Add tool to clean unused medias
This commit is contained in:
parent
626b59080e
commit
92146ba8e1
3 changed files with 65 additions and 2 deletions
|
@ -174,7 +174,7 @@ namespace controllers\internals;
|
|||
* @param int $id_user : User id
|
||||
* @param int $id : Entry id
|
||||
*
|
||||
* @return int : Number of removed rows
|
||||
* @return mixed bool|int : False on error, else number of removed rows
|
||||
*/
|
||||
public function delete_for_user(int $id_user, int $id_media): bool
|
||||
{
|
||||
|
@ -184,7 +184,19 @@ namespace controllers\internals;
|
|||
return false;
|
||||
}
|
||||
|
||||
unlink($media['path']);
|
||||
//Delete file
|
||||
try
|
||||
{
|
||||
$filepath = PWD_DATA . '/' . $media['path'];
|
||||
if (file_exists($filepath))
|
||||
{
|
||||
unlink($filepath);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->get_model()->delete_for_user($id_user, $id_media);
|
||||
}
|
||||
|
@ -225,6 +237,15 @@ namespace controllers\internals;
|
|||
return $this->get_model()->gets_for_received($id_received);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find medias that are not used
|
||||
* @return array
|
||||
*/
|
||||
public function gets_unused()
|
||||
{
|
||||
return $this->get_model()->gets_unused();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model for the Controller.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue