| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Copyright (c) 2019 Matias De lellis <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author Matias De lellis <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @license GNU AGPL version 3 or any later version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * This program is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * it under the terms of the GNU Affero General Public License as | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * published by the Free Software Foundation, either version 3 of the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * License, or (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * GNU Affero General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * You should have received a copy of the GNU Affero General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * along with this program. If not, see <http://www.gnu.org/licenses/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | namespace OCA\FaceRecognition\Service; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use OCA\FaceRecognition\Helper\Requirements; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use OCP\IConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use OCP\Files\IRootFolder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use OCP\Files\File; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use OCP\Files\Folder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use OCP\Files\Node; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use OCP\ITempManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use OCP\Files\IHomeStorage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | use OCP\Files\NotFoundException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | use OCA\Files_Sharing\External\Storage as SharingExternalStorage; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | class FileService { | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  | 	const NOMEDIA_FILE = ".nomedia"; | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 	const FACERECOGNITION_SETTINGS_FILE = ".facerecognition.json"; | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | 	/**  @var string|null */ | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  | 	private $userId; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  | 	/** @var IConfig Config */ | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  | 	private $config; | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  | 	/** @var IRootFolder */ | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | 	private $rootFolder; | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  | 	/** @var ITempManager */ | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  | 	private $tempManager; | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 1 |  | 	public function __construct($userId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	                            IConfig      $config, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	                            IRootFolder  $rootFolder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	                            ITempManager $tempManager) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 1 |  | 		$this->userId      = $userId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 1 |  | 		$this->config      = $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 1 |  | 		$this->rootFolder  = $rootFolder; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 68 | 1 |  | 		$this->tempManager = $tempManager; | 
            
                                                                        
                            
            
                                    
            
            
                | 69 | 1 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  | 	 * TODO: Describe exactly when necessary. | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 11 |  | 	public function setupFS(string $userId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 11 |  | 		\OC_Util::tearDownFS(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 11 |  | 		\OC_Util::setupFS($userId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 78 | 11 |  | 		$this->userId = $userId; | 
            
                                                                        
                            
            
                                    
            
            
                | 79 | 11 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  | 	 * @return Node | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  | 	 * @throws NotFoundException | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 2 |  | 	public function getFileById($fileId, $userId = null): Node { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 2 |  | 		$files = $this->rootFolder->getUserFolder($this->userId ?? $userId)->getById($fileId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 2 |  | 		if (count($files) === 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 1 |  | 			throw new NotFoundException(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 91 | 1 |  | 		return $files[0]; | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  | 	 * @return Node | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  | 	public function getFileByPath($fullpath, $userId = null): Node { | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  | 		$userFolder = $this->rootFolder->getUserFolder($this->userId); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  | 		$files = $this->rootFolder->getUserFolder($this->userId ?? $userId)->get($fullpath); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  | 		return $files; | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  | 	 * Checks if this file is located somewhere under .nomedia file and should be therefore ignored. | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  | 	 * Or with an .facerecognition.json setting file that disable tha analysis | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  | 	 * @param File $file File to search for | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  | 	 * @return bool True if file is located under .nomedia or .facerecognition.json that disabled | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  | 	 * analysis, false otherwise | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 112 | 1 |  | 	public function isUnderNoDetection(Node $node): bool { | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  | 		// If we detect .nomedia file anywhere on the path to root folder (id===null), bail out | 
            
                                                                        
                            
            
                                    
            
            
                | 114 | 1 |  | 		$parentNode = $node->getParent(); | 
            
                                                                        
                            
            
                                    
            
            
                | 115 | 1 |  | 		while (($parentNode instanceof Folder) && ($parentNode->getId() !== null)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 116 | 1 |  | 			$allowDetection = $this->allowsChildDetection($parentNode); | 
            
                                                                        
                            
            
                                    
            
            
                | 117 | 1 |  | 			if (!$allowDetection) | 
            
                                                                        
                            
            
                                    
            
            
                | 118 | 1 |  | 				return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 119 | 1 |  | 			$parentNode = $parentNode->getParent(); | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 121 | 1 |  | 		return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  | 	 * Checks if this folder has .nomedia file an .facerecognition.json setting file that | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  | 	 * disable that analysis. | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  | 	 * @param Folder $folder Folder to search for | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  | 	 * @return bool true if folder dont have an .nomedia file or .facerecognition.json that disabled | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  | 	 * analysis, false otherwise | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 132 | 3 |  | 	public function allowsChildDetection(Folder $folder): bool { | 
            
                                                                        
                            
            
                                    
            
            
                | 133 | 3 |  | 		if ($folder->nodeExists(FileService::NOMEDIA_FILE)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 134 | 2 |  | 			return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 136 | 3 |  | 		if ($folder->nodeExists(FileService::FACERECOGNITION_SETTINGS_FILE)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  | 			$file = $folder->get(FileService::FACERECOGNITION_SETTINGS_FILE); | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  | 			$settings = json_decode($file->getContent(), true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  | 			if ($settings === null || !array_key_exists('detection', $settings)) | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  | 				return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  | 			if ($settings['detection'] === 'off') | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  | 				return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 146 | 3 |  | 		return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  | 	 * Set this folder to enable or disable the analysis using the .facerecognition.json file. | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  | 	 * @param Folder $folder Folder to enable/disable for | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  | 	 * @return bool true if the change is done. False if failed. | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  | 	public function setAllowChildDetection(Folder $folder, bool $detection): bool { | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  | 		if ($folder->nodeExists(FileService::FACERECOGNITION_SETTINGS_FILE)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  | 			$file = $folder->get(FileService::FACERECOGNITION_SETTINGS_FILE); | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  | 			$settings = json_decode($file->getContent(), true); | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  | 			if ($settings === null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  | 				// Invalid json. | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  | 				return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  | 		else { | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  | 			$file = $folder->newFile(FileService::FACERECOGNITION_SETTINGS_FILE); | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  | 			$settings = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  | 		$settings['detection'] = $detection ? "on" : "off"; | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  | 		$file->putContent(json_encode($settings)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  | 		return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  | 	 * Returns if the file is inside a shared storage. | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 178 | 28 |  | 	public function isSharedFile(Node $node): bool { | 
            
                                                                        
                            
            
                                    
            
            
                | 179 | 28 |  | 		return $node->getStorage()->instanceOfStorage(SharingExternalStorage::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  | 	 * Returns if the file is inside HomeStorage. | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 185 | 28 |  | 	public function isUserFile(Node $node): bool { | 
            
                                                                        
                            
            
                                    
            
            
                | 186 | 28 |  | 		return $node->getStorage()->instanceOfStorage(IHomeStorage::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  | 	 * Returns if the Node is allowed based on preferences. | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 192 | 28 |  | 	public function isAllowedNode(Node $node): bool { | 
            
                                                                        
                            
            
                                    
            
            
                | 193 | 28 |  | 		if ($this->isUserFile($node)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 194 | 28 |  | 			return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 195 | 28 |  | 		} else if ($this->isSharedFile($node)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  | 			$handleSharedFiles = $this->config->getAppValue('facerecognition', 'handle-shared-files', 'false'); | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  | 			return ($handleSharedFiles === 'true'); | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 199 | 28 |  | 		return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 200 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 202 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 203 |  |  | 	 * Get a path to either the local file or temporary file | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  | 	 * @param File $file | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  | 	 * @param int $maxSize maximum size for temporary files | 
            
                                                                        
                            
            
                                    
            
            
                | 207 |  |  | 	 * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 208 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 209 |  |  | 	public function getLocalFile(File $file, int $maxSize = null): string { | 
            
                                                                        
                            
            
                                    
            
            
                | 210 |  |  | 		$useTempFile = $file->isEncrypted() || !$file->getStorage()->isLocal(); | 
            
                                                                        
                            
            
                                    
            
            
                | 211 |  |  | 		if ($useTempFile) { | 
            
                                                                        
                            
            
                                    
            
            
                | 212 |  |  | 			$absPath = $this->tempManager->getTemporaryFile(); | 
            
                                                                        
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 214 |  |  | 			$content = $file->fopen('r'); | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  | 			if ($maxSize !== null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  | 				$content = stream_get_contents($content, $maxSize); | 
            
                                                                        
                            
            
                                    
            
            
                | 217 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 218 |  |  | 			file_put_contents($absPath, $content); | 
            
                                                                        
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 220 |  |  | 			return $absPath; | 
            
                                                                        
                            
            
                                    
            
            
                | 221 |  |  | 		} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 222 |  |  | 			return $file->getStorage()->getLocalFile($file->getInternalPath()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 223 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 224 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 226 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 227 |  |  | 	 * Return all images from a given folder. | 
            
                                                                        
                            
            
                                    
            
            
                | 228 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 229 |  |  | 	 * TODO: It is inefficient since it copies the array recursively. | 
            
                                                                        
                            
            
                                    
            
            
                | 230 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 231 |  |  | 	 * @param Folder $folder Folder to get images from | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  | 	 * @return array List of all images and folders to continue recursive crawling | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 234 | 10 |  | 	public function getPicturesFromFolder(Folder $folder, $results = array()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 235 | 10 |  | 		$nodes = $folder->getDirectoryListing(); | 
            
                                                                        
                            
            
                                    
            
            
                | 236 | 10 |  | 		foreach ($nodes as $node) { | 
            
                                                                        
                            
            
                                    
            
            
                | 237 | 8 |  | 			if (!$this->isAllowedNode($node)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  | 				continue; | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 240 | 8 |  | 			if ($node instanceof Folder && $this->allowsChildDetection($node)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 241 | 3 |  | 				$results = $this->getPicturesFromFolder($node, $results); | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 243 | 8 |  | 			else if ($node instanceof File) { | 
            
                                                                        
                            
            
                                    
            
            
                | 244 | 8 |  | 				if (Requirements::isImageTypeSupported($node->getMimeType())) { | 
            
                                                                        
                            
            
                                    
            
            
                | 245 | 7 |  | 					$results[] = $node; | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 249 | 10 |  | 		return $results; | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  | 	 * Create a temporary file and return the path | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  | 	public function getTemporaryFile(string $postFix = ''): string { | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  | 		return $this->tempManager->getTemporaryFile($postFix); | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 259 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 260 |  |  | 	 * Remove any temporary file from the service. | 
            
                                                                        
                            
            
                                    
            
            
                | 261 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 	public function clean() { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 263 |  |  | 		$this->tempManager->clean(); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 264 |  |  | 	} | 
            
                                                                        
                                                                
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 266 |  |  | } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 267 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths