diff --git a/VERSIONS_HOTLINE/81124 b/VERSIONS_HOTLINE/81124
new file mode 100644
index 0000000000000000000000000000000000000000..45f3dba511fc5f910b9fcb615724886fbaf64b02
--- /dev/null
+++ b/VERSIONS_HOTLINE/81124
@@ -0,0 +1 @@
+ - ticket #81124 : Cosmogramme : correction de la précision du calcul des tailles minimum des fichiers à intégrer
\ No newline at end of file
diff --git a/cosmogramme/php/fonctions/fonctions_base.php b/cosmogramme/php/fonctions/fonctions_base.php
index 3105d7ae374ea396c1ff245fcfde29825900e727..b70ea8ed994477b64bca266e20fbca521d7bb999 100644
--- a/cosmogramme/php/fonctions/fonctions_base.php
+++ b/cosmogramme/php/fonctions/fonctions_base.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 //////////////////////////////////////////////////////////////////////////////
 //   FONCTIONS DE BASE
@@ -43,9 +43,9 @@ function lireConfig($fic)
 	}
 	return $cfg;
 }
-// ---------------------------------------------------	
+// ---------------------------------------------------
 // Clef se securite
-// ---------------------------------------------------	
+// ---------------------------------------------------
 function getClefSecurite()
 {
 	$clef="IMG".date("DxzxYxM")."VIG";
@@ -83,52 +83,4 @@ function rendBouton($libelle,$script,$arguments,$confirmation="")
 	return $url;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////
-// DEBUG
-///////////////////////////////////////////////////////////////////////////////////////
-
-// Affiche le contenu d'un tableau
-function dump_array( $tableau)
-{
-	print( "<br><br><big><b>Tableau</b></big>");
-	print("<br><br><pre>");
-	print_r($tableau);
-	print("</pre><br><br>");
-}
-function dump_var($texte)
-{
-	print(htmlspecialchars($texte));
-}
-function dump_ascii($chaine)
-{
-	for($i=0;$i<strlen($chaine);$i++)
-	{
-		$car=strmid($chaine,$i,1);
-		print("CHAR=".$car."=".ord($car).BR);
-	}
-}
-function traceDebug($trace=false,$exit=false)
-{
-	// Script et fonction
-	$stack=debug_backtrace();
-	$lig=$stack[1];
-	print('<div class="trace_debug">');
-	if($niveau==100) dump_array($stack);
-	else
-	{
-		print("<b>Script : </b>". $lig["file"]);
-		print(" - <b>Ligne : </b>". $lig["line"]);
-		if($lig["class"]) print(" - <b>Classe : </b>". $lig["class"]);
-		print(" - <b>Fonction : </b>". $lig["function"].BR);
-		// Données
-		if($trace)
-		{
-			if(gettype($trace) == "array") dump_array($trace);
-			else print('<b>Message : </b>'.$trace.BR);
-		}
-	}
-	print('</div>');
-	flush();
-	if($exit == true) exit;
-}
 ?>
\ No newline at end of file
diff --git a/cosmogramme/php/fonctions/sql.php b/cosmogramme/php/fonctions/sql.php
index 1d8c0618bf5540e96ebb0aa96be4c9b06be8817b..479ca335dd324115850ca31d3c6498e72c44ca90 100644
--- a/cosmogramme/php/fonctions/sql.php
+++ b/cosmogramme/php/fonctions/sql.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 //////////////////////////////////////////////////////////////////////////////////////////
 // OPAC3 - Fonctions sql simplifi�es
@@ -58,23 +58,6 @@ function fetchAll($req,$num=false)
 	return $sql->fetchAll($req,$num);
 }
 
-// ---------------------------------------------------
-// Renvoie un where a partir d'un array de conditions
-// ---------------------------------------------------
-function getWhereSql($conditions)
-{
-	if(!$conditions) return "";
-	if(gettype($conditions)=="string") $conditions[0]=$conditions;
-	foreach($conditions as $condition)
-	{
-		if(!trim($condition)) continue;
-		if($where) $where.=" and ";
-		$where.=$condition;
-	}
-	if(!$where) return "";
-	$where=" where ".$where;
-	return $where;
-}
 
 // ---------------------------------------------------
 // Requete update
@@ -93,13 +76,3 @@ function sqlInsert($table,$data)
 	global $sql;
 	return $sql->insert($table,$data);
 }
-// ---------------------------------------------------
-// Renvoie une clause limt sql
-// ---------------------------------------------------
-function getLimitSql($nb_par_page,$page)
-{
-	if(!$page) $page=1;
-	$limit = ($page-1) * $nb_par_page;
-	$limit = " LIMIT ".$limit.",". $nb_par_page;
-	return $limit;
-}
\ No newline at end of file
diff --git a/cosmogramme/php/fonctions/string.php b/cosmogramme/php/fonctions/string.php
index d7df060caeb0c0760ccce6b07ee21783a0c60286..15bd25cce9cb1abdc4698530e7c04bd8d318a269 100644
--- a/cosmogramme/php/fonctions/string.php
+++ b/cosmogramme/php/fonctions/string.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 //////////////////////////////////////////////////////////////////////////////////////
 //                  FONCTIONS CHAINES DE CARACTERES
@@ -51,15 +51,5 @@ function strScan( $chaine, $cherche, $posDeb=0)
 	return -1;
 }
 
-function strScanReverse( $chaine, $cherche, $pos )
-{
-	$len = strLen($cherche);
-	if( $pos == -1 ) $pos = strLen($chaine);
-	for( $i=$pos; $i>=0; $i-- )
-	{
-		if( substr( $chaine, $i, $len ) == $cherche ) return $i;
-	}
-	return -1;
-}
 
 ?>
\ No newline at end of file
diff --git a/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php b/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php
index a82d99b7e37acfc32250ce1879f708670a225a15..602a1eef9ba61f9fac8ba6d788362510e298fd9a 100644
--- a/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php
+++ b/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php
@@ -188,19 +188,17 @@ class Class_Cosmogramme_Integration_PhasePrepareIntegrations extends Class_Cosmo
       return false;
 
     $file_type = $profil->getTypeFichier();
-    $minsize = $majauto->getTailleMinImportTotal();
+    $minsize = $majauto->getTailleMinImportTotal() * 1024 * 1024;
     $type_operation = $majauto->getTypeOperation();
 
     if ($minsize > 0 && $file_type == 0 && $type_operation == 2) {
-      $file_size = filesize($file);
-      if ($file_size > 0)
-        $file_size = (int) (($file_size / 1024) / 1024);
-
+      $file_size = $this->getFileSystem()->filesize($file);
       if ($file_size < $minsize) {
         $this->_log
           ->log(sprintf('<span class="rouge">%s</span></td>',
-                        $this->_('Le fichier est trop petit : %s mo -> taille minimum attendue : %s mo',
-                                 $file_size, $minsize)));
+                        $this->_('Le fichier est trop petit : %s o -> taille minimum attendue : %s o',
+                                 $file_size,
+                                 $minsize)));
         return false;
       }
     }
diff --git a/library/Class/Xml.php b/library/Class/Xml.php
index 131a1f4b4defbbdbc6d79d31e34fa3e343b1161b..75f509220495a96d3b6209d5c41ffce8eb9167e1 100644
--- a/library/Class/Xml.php
+++ b/library/Class/Xml.php
@@ -40,9 +40,17 @@ class Class_Xml {
   }
 
 
+  public function lire_fichier( $fic) {
+    @$handle = fopen( $fic, "r") or erreur_admin( "Impossible d'ouvrir le fichier : " .$fic );
+    $data=fread ($handle, filesize ($fic));
+    fclose($handle);
+    return $data;
+  }
+
+
   public function open_fichier($fic) {
     include_once 'fonctions/file_system.php';
-    $data = lire_fichier($fic);
+    $data = $this->lire_fichier($fic);
     $parser = xml_parser_create("ISO-8859-1");
     xml_parse_into_struct($parser, $data, $this->valeurs, $this->index);
     xml_parser_free($parser);
@@ -108,22 +116,6 @@ class Class_Xml {
   }
 
 
-  public function dump_node($node)  {
-    if($this->valeurs[$node]["type"]=="complete"){dump_array($this->valeurs[$node]); return true;}
-    for($i=$node; $i< 32000; $i++)
-    {
-      if(!$this->valeurs[$i]) return false;
-      if($this->fin_node($node, $i) == true)
-      {
-        //dump_array($data);
-        return true;
-      }
-      //$data[]= $this->valeurs[$i];
-      dump_array($this->valeurs[$i]);flush();
-    }
-  }
-
-
   public function get_value($node) {
     return $this->valeurs[$node]["value"];
   }
@@ -135,32 +127,6 @@ class Class_Xml {
   }
 
 
-  public function dump_xml($format) {
-    if(strToUpper($format)=="XML") {
-      foreach($this->valeurs as $balise) {
-        $balise["tag"]=strToLower($balise["tag"]);
-        $data.=str_repeat("&nbsp;", 5 * $balise["level"]);
-        if($balise["type"] == "close" ) $data.="@D@/"; else $data.="@D@";
-        $data.= '<font color="#772B1A">'. $balise["tag"] .'</font>';
-        if($balise["attributes"]) {
-          foreach( $balise["attributes"] as $key => $value) $data.=' <font color="#ff0000">'.strToLower($key).'</font><font color="#0000ff">="</font><font color="#ff0000">'.$value.'</font><font color="#0000ff">"</font>';
-        }
-        if($balise["type"]=="complete" and $balise["value"]) $data.= "@F@<b>" .$balise["value"] ."</b>@D@/".'<font color="#772B1A">'.$balise["tag"] .'</font>';
-        $data.= "@F@";
-        $data.= BR;
-      }
-      $data = str_replace("@D@/", '<font color="#0000ff">&lt;/</font>', $data);
-      $data = str_replace("@D@", '<font color="#0000ff">&lt;</font>', $data);
-      $data = str_replace("@F@", '<font color="#0000ff">&gt;</font>', $data);
-      print($data);
-      return;
-    }
-
-    dump_array($this->index);
-    dump_array($this->valeurs);
-  }
-
-
   public function fin_node($node, $test) {
     if($this->valeurs[$node]["type"]=="complete")
       return true;
diff --git a/library/fonctions/error.php b/library/fonctions/error.php
index 99ad1a39cc5a3522942e6005c4bda1d51063e169..908a07c57c0e06b8824ed65b5cfc02e204ea6ff2 100644
--- a/library/fonctions/error.php
+++ b/library/fonctions/error.php
@@ -16,36 +16,9 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
-function logErrorMessage($message) 
-{ 
-    echo '<b>keskil pass</b><br />'.$message.'<br />'; 
-}
-
-function traceDebug($trace,$exit=false)
-{
-  // Script et fonction
-  $stack=debug_backtrace();
-  $lig=$stack[1];
-  print('<div style="margin-left:10px;margin-bottom:5px;margin-top:5px;border:1px solid;border-color:#E0E0E0;background-color:#CCFF99;padding:5px;text-align:left">');
-  if($niveau==100) dump_array($stack);
-  else
-  {
-    print("<b>Script : </b>". $lig["file"]);
-    print(" - <b>Ligne : </b>". $lig["line"]);
-    if($lig["class"]) print(" - <b>Classe : </b>". $lig["class"]);
-    print(" - <b>Fonction : </b>". $lig["function"].BR);
-    // Données
-    if($trace)
-    {
-      $type=gettype($trace);
-      if( $type == "array" or $type=="object") dump_array($trace);
-      else print('<b>Message : </b>'.$trace.BR);
-    }
-  }
-  print('</div>');
-  flush();
-  if($exit == true) exit;
+function logErrorMessage($message) {
+    echo '<b>Error</b><br />'.$message.'<br />';
 }
 ?>
\ No newline at end of file
diff --git a/library/fonctions/file_system.php b/library/fonctions/file_system.php
deleted file mode 100644
index 25ae3671907bdc13237bffd6078162cb62bf4ee8..0000000000000000000000000000000000000000
--- a/library/fonctions/file_system.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
- *
- * BOKEH is free software; you can redistribute it and/or modify
- * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
- * the Free Software Foundation.
- *
- * There are special exceptions to the terms and conditions of the AGPL as it
- * is applied to this software (see README file).
- *
- * BOKEH is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
- * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
- */
-/*
- * FONCTIONS DE TRAITEMENTS REPERTOIRES ET FICHIERS
- */
-
-// Lit le contenu entier d'un fichier
-function lire_fichier( $fic)
-{
-  @$handle = fopen( $fic, "r") or erreur_admin( "Impossible d'ouvrir le fichier : " .$fic );
-  $data=fread ($handle, filesize ($fic));
-  fclose($handle);
-  return $data;
-}
-
-// Lit un fichier en éliminant les lignes vides et les commentaires
-function lire_fichier_ressource( $fic )
-{
-  $lig = @file( $fic ) or erreur_admin( "Impossible d'ouvrir le fichier : " . $fic);
-  for( $i = 0; $i < count($lig); $i++)
-  {
-    $lig[$i] = trim($lig[$i]);
-    if( ! $lig[$i] or strLeft( $lig[$i],2 ) == "//") continue;
-    $data .= NL.$lig[$i];
-  }
-  return $data;
-}
-
-// Rend tous les fichiers de tous les dossiers et sous-dossiers d'une racine
-function parse_dossier( $root )
-{
-  if( file_exists($root) == false ) return false;
-  $liste = array();
-  @$dir = opendir( $root) or die("Impossible d'ouvrir le dossier : " .$root);
-  while (($file = readdir($dir)) !== false) 
-  {
-    if( subStr( $file, 0, 1 )!= ".") 
-    {
-      if(filetype($root. "/" .$file) == "dir")
-      {
-        $liste1 = parse_dossier( $root. "/" .$file);
-        $liste = array_merge( $liste, $liste1); 
-      }
-      else
-      {
-        $index = count($liste);
-        $liste[$index][0]= $root;
-        $liste[$index][1]= $file;
-      }
-    }
-  }
-  closedir( $dir);
-  return $liste;
-}
-?>
\ No newline at end of file
diff --git a/library/fonctions/sql.php b/library/fonctions/sql.php
index 8564a2a9c4bd3989b425d628c642eebb28a31bdb..0f36293ac89eaecf33ab1756d7114c171ac8174b 100644
--- a/library/fonctions/sql.php
+++ b/library/fonctions/sql.php
@@ -46,27 +46,6 @@ function fetchAll($req, $num=false) {
 }
 
 
-function getWhereSql($conditions) {
-  if (!$conditions)
-    return '';
-
-  if ('string' == gettype($conditions))
-    $conditions = [$conditions];
-
-  $clauses = [];
-  foreach ($conditions as $condition) {
-    if (!$trimmed = trim($condition))
-      continue;
-    $clauses[] = $trimmed;
-  }
-
-  if (0 == count($clauses))
-    return '';
-
-  return ' where ' . implode(' and ', $clauses);
-}
-
-
 function sqlUpdate($req, $data, $force_quote=false) {
   return Zend_Registry::get('sql')->update($req, $data, $force_quote);
 }
@@ -77,10 +56,4 @@ function sqlInsert($table, $data, $force_quote=false) {
 }
 
 
-function getLimitSql($nb_par_page, $page) {
-  if(!$page) $page = 1;
-  $limit = ($page-1) * $nb_par_page;
-  return ' LIMIT ' . $limit . ',' . $nb_par_page;
-}
-
 ?>
\ No newline at end of file
diff --git a/library/fonctions/string.php b/library/fonctions/string.php
index 9f430f8a42c4cb3b0d0fde5ea385b826f3c909ca..123c87e2d7d61879a99682bc518b7bb31fcd3821 100644
--- a/library/fonctions/string.php
+++ b/library/fonctions/string.php
@@ -23,16 +23,6 @@
 //
 /////////////////////////////////////////////////////////////////////////////////////
 
-//----------------------------------------------------------------------------------
-// Debug dans un fichier log
-//----------------------------------------------------------------------------------
-function debug_log($chaine,$stop=false)
-{
-  $handle=fopen(USERFILESPATH."/debug.log","a");
-  fwrite($handle,$chaine.chr(13).chr(10));
-  fclose($handle);
-  if($stop==true) exit;
-}
 
 //----------------------------------------------------------------------------------
 // Rend une variable admin
@@ -61,16 +51,6 @@ function getVarListeCosmogramme($clef)
   return $liste;
 }
 
-//----------------------------------------------------------------------------------
-// Affichage d'un tableau pour debugging
-//----------------------------------------------------------------------------------
-function dump_array( $tableau)
-{
-  print( "<br><br><big><b>Tableau</b></big>");
-  print("<br><br><pre>");
-  print_r($tableau);
-  print("</pre><br><br>");
-}
 
 //----------------------------------------------------------------------------------
 // Formattage de date
@@ -152,20 +132,6 @@ function strScan( $chaine, $cherche, $posDeb = 0)
   return -1;
 }
 
-function strScanReverse( $chaine, $cherche, $pos ) {
-
-  $chaine = convertFromUtf8($chaine);
-  $cherche = convertFromUtf8($cherche);
-
-  $len = strLen($cherche);
-  if( $pos == -1 )
-    $pos = strLen($chaine);
-  for( $i=$pos; $i>=0; $i-- ) {
-    if( substr( $chaine, $i, $len ) == $cherche )
-      return $i;
-  }
-  return -1;
-}
 
 // Cherche une valeur dans un tableau et renvoie l'indice sinon -1
 function array_find( $tableau, $valeur )
diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php
index c6dac7b3f683e5732d165f280dff6457abfce45c..c6192da2af56313d99ec40694e3b79711b183eeb 100644
--- a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php
+++ b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php
@@ -32,6 +32,18 @@ abstract class PhasePrepareIntegrationsWithOAITestCase
                         ->with ('ftp/my-library.net/transferts/foo/mylibrarytotal.txt')
                         ->answers(true)
 
+                        ->whenCalled('filesize')
+                        ->with ('ftp/my-library.net/transferts/foo/mylibrarytotal.txt')
+                        ->answers(11000000)
+
+                        ->whenCalled('is_file')
+                        ->with ('ftp/my-library.net/transferts/foo/toosmall.txt')
+                        ->answers(true)
+
+                        ->whenCalled('filesize')
+                        ->with ('ftp/my-library.net/transferts/foo/toosmall.txt')
+                        ->answers(1000000)
+
                         ->whenCalled('is_file')
                         ->with ('ftp/my-library.net/transferts/foo/20180517mylibraryincr.txt')
                         ->answers(true)
@@ -135,7 +147,7 @@ abstract class PhasePrepareIntegrationsWithOAITestCase
                                         'type_doc' => 0,
                                         'nom_fichier' => 'foo/mylibrarytotal.txt',
                                         'rang' => 100,
-                                        'taille_min_import_total' => 0]);
+                                        'taille_min_import_total' => 10]);
 
     $this->fixture('Class_IntMajAuto', ['id' => 101,
                                         'id_prog' => 101,
@@ -159,6 +171,20 @@ abstract class PhasePrepareIntegrationsWithOAITestCase
                                         'rang' => 102,
                                         'taille_min_import_total' => 0]);
 
+
+
+    $this->fixture('Class_IntMajAuto', ['id' => 104,
+                                        'id_prog' => 104,
+                                        'id_bib' => 2,
+                                        'libelle' => 'Notices - too small',
+                                        'profil' => 102,
+                                        'type_operation' => 2,
+                                        'type_doc' => 0,
+                                        'nom_fichier' => 'foo/toosmall.txt',
+                                        'rang' => 100,
+                                        'taille_min_import_total' => 10]);
+
+
     $this->fixture('Class_Cosmogramme_Integration',
                    ['id' => 1,
                     'id_bib' => 2,
@@ -249,6 +275,12 @@ class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOA
   }
 
 
+  /** @test */
+  public function logShouldContainsFileTooSmall() {
+    $this->assertLogContains('<td class="blank">foo/toosmall.txt</td><td class="blank"> <span class="rouge">Le fichier est trop petit : 1000000 o -> taille minimum attendue : 10485760 o');
+  }
+
+
   /**
    * @expectedException Class_Cosmogramme_Integration_PhasePrepareIntegrationsException
    * @expectedExceptionMessage La variable ftp_path n'est pas définie