From cc7d5f01690f732f0a6a4e0dd6f4ecbb0ea889bd Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@afi-sa.fr>
Date: Fri, 13 Jul 2018 11:31:21 +0200
Subject: [PATCH] hotline #76959 : fix RT + used space bug

---
 application/modules/admin/controllers/RecordsController.php | 3 ++-
 library/Class/FileManager.php                               | 4 +---
 library/Class/FileManager/FileSystem.php                    | 5 +++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/application/modules/admin/controllers/RecordsController.php b/application/modules/admin/controllers/RecordsController.php
index c3d0296bb7b..9c92ea3ef03 100644
--- a/application/modules/admin/controllers/RecordsController.php
+++ b/application/modules/admin/controllers/RecordsController.php
@@ -30,8 +30,9 @@ class Admin_RecordsController extends ZendAfi_Controller_Action {
     if ($album = $record->getAlbum()){
       $album->createThumbnail();
       $url_vignette = $album->getThumbnailUrl();
+      
       $record->setUrlVignette($url_vignette);
-      $record->setUrlImage($url_vignette);
+      $record->setUrlImage(($poster = $album->getPoster()) ? $poster : $url_vignette);
       $record->save();
 
       $this->_helper->notify($this->_('Vignette réinitialisée pour "%s"', $record->getTitrePrincipal()));
diff --git a/library/Class/FileManager.php b/library/Class/FileManager.php
index a162d4e64d1..f0214ce5261 100644
--- a/library/Class/FileManager.php
+++ b/library/Class/FileManager.php
@@ -181,9 +181,7 @@ class Class_FileManager extends Class_Entity {
 
 
   protected static function _isPath($url_or_path) {
-    return Class_Url::isAnUrl($url_or_path)
-      ? false
-      : true;
+    return !Class_Url::isAnUrl($url_or_path);
   }
 
 
diff --git a/library/Class/FileManager/FileSystem.php b/library/Class/FileManager/FileSystem.php
index 275a3bb4dfc..33339fdfa2b 100644
--- a/library/Class/FileManager/FileSystem.php
+++ b/library/Class/FileManager/FileSystem.php
@@ -231,8 +231,9 @@ class Class_FileManager_FileSystem {
     $path = $root->getRealpath();
     $total = Class_AdminVar::get('ALLOWED_DISK_SPACE') * 1024 * 1024;
     $used = exec(sprintf('du -0sb %s', $path));
-    $used = filter_var($used, FILTER_SANITIZE_NUMBER_INT);
-    $free = $total >= $used ? $total - $used : 0;
+    $parts = explode("\t", $used);
+    $used = (int)$parts[0];
+    $free = ($total >= $used) ? ($total - $used) : 0;
 
     $used_percent = sprintf('%.2f',($used / $total) * 100) . '%';
 
-- 
GitLab