@@ -67,9 +67,7 @@ private function deleteAvatars(OutputInterface $output, bool $dryMode): void {
6767
6868 try {
6969 $ avatar ->remove ();
70- } catch (NotFoundException $ e ) {
71- // continue
72- } catch (NotPermittedException $ e ) {
70+ } catch (NotFoundException |NotPermittedException ) {
7371 // continue
7472 }
7573 }
@@ -91,8 +89,8 @@ private function getAvatarsToDelete(): \Iterator {
9189 private function deletePreviews (OutputInterface $ output , bool $ dryMode ): void {
9290 $ previewsToDeleteCount = 0 ;
9391
94- foreach ($ this ->getPreviewsToDelete () as [ ' path ' => $ filePath , ' preview ' => $ preview ] ) {
95- $ output ->writeln ('Deleting previews for ' . $ filePath , OutputInterface::VERBOSITY_VERBOSE );
92+ foreach ($ this ->getPreviewsToDelete () as $ preview ) {
93+ $ output ->writeln ('Deleting preview ' . $ preview -> getName () . ' for fileId ' . $ preview -> getFileId () , OutputInterface::VERBOSITY_VERBOSE );
9694
9795 $ previewsToDeleteCount ++;
9896
@@ -107,28 +105,13 @@ private function deletePreviews(OutputInterface $output, bool $dryMode): void {
107105 }
108106
109107 /**
110- * @return \Iterator<array{path: string, preview: Preview} >
108+ * @return \Generator< Preview>
111109 */
112- private function getPreviewsToDelete (): \Iterator {
113- $ qb = $ this ->connection ->getQueryBuilder ();
114- $ qb ->select ('fileid ' , 'path ' )
115- ->from ('filecache ' )
116- ->where (
117- $ qb ->expr ()->orX (
118- $ qb ->expr ()->eq ('mimetype ' , $ qb ->createNamedParameter ($ this ->mimeTypeLoader ->getId ('text/plain ' ))),
119- $ qb ->expr ()->eq ('mimetype ' , $ qb ->createNamedParameter ($ this ->mimeTypeLoader ->getId ('text/markdown ' ))),
120- $ qb ->expr ()->eq ('mimetype ' , $ qb ->createNamedParameter ($ this ->mimeTypeLoader ->getId ('text/x-markdown ' )))
121- )
122- );
123-
124- $ cursor = $ qb ->executeQuery ();
125-
126- while ($ row = $ cursor ->fetch ()) {
127- foreach ($ this ->previewService ->getAvailablePreviewForFile ($ row ['fileid ' ]) as $ preview ) {
128- yield ['path ' => $ row ['path ' ], 'preview ' => $ preview ];
129- }
130- }
131-
132- $ cursor ->closeCursor ();
110+ private function getPreviewsToDelete (): \Generator {
111+ return $ this ->previewService ->getPreviewsForMimeTypes ([
112+ $ this ->mimeTypeLoader ->getId ('text/plain ' ),
113+ $ this ->mimeTypeLoader ->getId ('text/markdown ' ),
114+ $ this ->mimeTypeLoader ->getId ('text/x-markdown ' ),
115+ ]);
133116 }
134117}
0 commit comments