2828use  Symfony \Component \Console \Output \OutputInterface ;
2929
3030/** 
31-  * @psalm-type StorageInfo array{numeric_id: int, id: string, available: bool, last_checked: ?\DateTime, files: int} 
31+  * @psalm-type StorageInfo array{numeric_id: int, id: string, available: bool, last_checked: ?\DateTime, files: int, mount_id: ?int } 
3232 */ 
3333class  FileUtils {
3434	public  function  __construct (
@@ -245,12 +245,13 @@ public function getNumericStorageId(string $id): ?int {
245245	 */ 
246246	public  function  getStorage (int  $ idarray  {
247247		$ query$ this connection ->getQueryBuilder ();
248- 		$ queryselect ('numeric_id ' , 'id ' , 'available ' , 'last_checked ' )
248+ 		$ queryselect ('numeric_id ' , 's. id , 'available ' , 'last_checked '  ,  ' mount_id '
249249			->selectAlias ($ queryfunc ()->count ('fileid ' ), 'files ' )
250250			->from ('storages ' , 's ' )
251251			->innerJoin ('s ' , 'filecache ' , 'f ' , $ queryexpr ()->eq ('f.storage ' , 's.numeric_id ' ))
252+ 			->leftJoin ('s ' , 'mounts ' , 'm ' , $ queryexpr ()->eq ('s.numeric_id ' , 'm.storage_id ' ))
252253			->where ($ queryexpr ()->eq ('s.numeric_id ' , $ querycreateNamedParameter ($ idPARAM_INT )))
253- 			->groupBy ('s.numeric_id ' , 's.id ' , 's.available ' , 's.last_checked ' );
254+ 			->groupBy ('s.numeric_id ' , 's.id ' , 's.available ' , 's.last_checked ' ,  ' mount_id ' 
254255		$ row$ queryexecuteQuery ()->fetch ();
255256		if  ($ row
256257			return  [
@@ -259,6 +260,7 @@ public function getStorage(int $id): ?array {
259260				'files '  => $ row'files ' ],
260261				'available '  => (bool )$ row'available ' ],
261262				'last_checked '  => $ row'last_checked ' ] ? new  \DateTime ('@ '  . $ row'last_checked ' ]) : null ,
263+ 				'mount_id '  => $ row'mount_id ' ],
262264			];
263265		} else  {
264266			return  null ;
@@ -272,11 +274,12 @@ public function getStorage(int $id): ?array {
272274	 */ 
273275	public  function  listStorages (?int  $ limit\Iterator   {
274276		$ query$ this connection ->getQueryBuilder ();
275- 		$ queryselect ('numeric_id ' , 'id ' , 'available ' , 'last_checked ' )
277+ 		$ queryselect ('numeric_id ' , 's. id , 'available ' , 'last_checked '  ,  ' mount_id '
276278			->selectAlias ($ queryfunc ()->count ('fileid ' ), 'files ' )
277279			->from ('storages ' , 's ' )
278280			->innerJoin ('s ' , 'filecache ' , 'f ' , $ queryexpr ()->eq ('f.storage ' , 's.numeric_id ' ))
279- 			->groupBy ('s.numeric_id ' , 's.id ' , 's.available ' , 's.last_checked ' )
281+ 			->leftJoin ('s ' , 'mounts ' , 'm ' , $ queryexpr ()->eq ('s.numeric_id ' , 'm.storage_id ' ))
282+ 			->groupBy ('s.numeric_id ' , 's.id ' , 's.available ' , 's.last_checked ' , 'mount_id ' )
280283			->orderBy ('files ' , 'DESC ' );
281284		if  ($ limitnull ) {
282285			$ querysetMaxResults ($ limit
@@ -289,6 +292,7 @@ public function listStorages(?int $limit): \Iterator {
289292				'files '  => $ row'files ' ],
290293				'available '  => (bool )$ row'available ' ],
291294				'last_checked '  => $ row'last_checked ' ] ? new  \DateTime ('@ '  . $ row'last_checked ' ]) : null ,
295+ 				'mount_id '  => $ row'mount_id ' ],
292296			];
293297		}
294298	}
@@ -304,6 +308,7 @@ public function formatStorage(array $storage): array {
304308			'files '  => $ storage'files ' ],
305309			'available '  => $ storage'available ' ] ? 'true '  : 'false ' ,
306310			'last_checked '  => $ storage'last_checked ' ]?->format(\DATE_ATOM ),
311+ 			'external_mount_id '  => $ storage'mount_id ' ],
307312		];
308313	}
309314
0 commit comments