@@ -79,8 +79,8 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
7979 if ($ this ->maxExecutionTime > 0 && time () - $ startTime > $ this ->maxExecutionTime ) {
8080 return ;
8181 }
82- $ files = $ this ->rootFolder ->getById ($ queueFile ->getFileId ());
83- if (count ( $ files ) === 0 ) {
82+ $ file = $ this ->rootFolder ->getFirstNodeById ($ queueFile ->getFileId ());
83+ if ($ file === null ) {
8484 try {
8585 $ this ->logger ->debug ('removing ' .$ queueFile ->getFileId ().' from ' .$ model .' queue because it couldn \'t be found ' );
8686 $ this ->queue ->removeFromQueue ($ model , $ queueFile );
@@ -90,8 +90,8 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
9090 continue ;
9191 }
9292 try {
93- if ($ files [ 0 ] ->getSize () == 0 ) {
94- $ this ->logger ->debug ('File is empty: ' . $ files [ 0 ] ->getPath ());
93+ if ($ file ->getSize () == 0 ) {
94+ $ this ->logger ->debug ('File is empty: ' . $ file ->getPath ());
9595 try {
9696 $ this ->logger ->debug ('removing ' . $ queueFile ->getFileId () . ' from ' . $ model . ' queue ' );
9797 $ this ->queue ->removeFromQueue ($ model , $ queueFile );
@@ -100,14 +100,14 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
100100 }
101101 continue ;
102102 }
103- $ path = $ this ->getConvertedFilePath ($ files [ 0 ] );
103+ $ path = $ this ->getConvertedFilePath ($ file );
104104 if (in_array ($ model , [ImagenetClassifier::MODEL_NAME , LandmarksClassifier::MODEL_NAME , ClusteringFaceClassifier::MODEL_NAME ], true )) {
105105 // Check file data size
106106 $ filesize = filesize ($ path );
107107 if ($ filesize !== false ) {
108108 $ filesizeMb = $ filesize / (1024 * 1024 );
109109 if ($ filesizeMb > 8 ) {
110- $ this ->logger ->debug ('File is too large for classifier: ' . $ files [ 0 ] ->getPath ());
110+ $ this ->logger ->debug ('File is too large for classifier: ' . $ file ->getPath ());
111111 try {
112112 $ this ->logger ->debug ('removing ' . $ queueFile ->getFileId () . ' from ' . $ model . ' queue ' );
113113 $ this ->queue ->removeFromQueue ($ model , $ queueFile );
@@ -120,7 +120,7 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
120120 // Check file dimensions
121121 $ dimensions = @getimagesize ($ path );
122122 if (isset ($ dimensions ) && $ dimensions !== false && ($ dimensions [0 ] > 1024 || $ dimensions [1 ] > 1024 )) {
123- $ this ->logger ->debug ('File dimensions are too large for classifier: ' . $ files [ 0 ] ->getPath ());
123+ $ this ->logger ->debug ('File dimensions are too large for classifier: ' . $ file ->getPath ());
124124 try {
125125 $ this ->logger ->debug ('removing ' . $ queueFile ->getFileId () . ' from ' . $ model . ' queue ' );
126126 $ this ->queue ->removeFromQueue ($ model , $ queueFile );
@@ -132,7 +132,7 @@ public function classifyFiles(string $model, array $queueFiles, int $timeout): \
132132 }
133133 $ paths [] = $ path ;
134134 $ processedFiles [] = $ queueFile ;
135- $ fileNames [] = $ files [ 0 ] ->getPath ();
135+ $ fileNames [] = $ file ->getPath ();
136136 } catch (NotFoundException |InvalidPathException $ e ) {
137137 $ this ->logger ->warning ('Could not find file ' , ['exception ' => $ e ]);
138138 try {
0 commit comments