@@ -124,9 +124,7 @@ private function queueMoves($type, $moveInterval, Storage $fromStorage, Storage
124
124
foreach ($ query ->iterate (null , AbstractQuery::HYDRATE_SCALAR ) as $ row ) {
125
125
$ storageFile = $ row [0 ];
126
126
127
- $ this ->executeMove ($ storageFile ['id ' ], $ toStorage , $ output );
128
-
129
- $ queued ++;
127
+ $ queued += $ this ->executeMove ($ storageFile ['id ' ], $ toStorage , $ output );
130
128
}
131
129
132
130
return $ queued ;
@@ -144,7 +142,6 @@ private function queueDeletes($type, $deleteInterval, $limit, OutputInterface $o
144
142
/** @var EntityManager $em */
145
143
$ em = $ this ->getContainer ()->get ('doctrine ' )->getManager ();
146
144
147
-
148
145
$ qb = $ em ->createQueryBuilder ()
149
146
->select ('s ' )
150
147
->from (StorageFile::class, 's ' )
@@ -166,9 +163,7 @@ private function queueDeletes($type, $deleteInterval, $limit, OutputInterface $o
166
163
foreach ($ query ->iterate (null , AbstractQuery::HYDRATE_SCALAR ) as $ row ) {
167
164
$ storageFile = $ row [0 ];
168
165
169
- $ this ->executeDelete ($ storageFile ['id ' ], $ output );
170
-
171
- $ queued ++;
166
+ $ queued += $ this ->executeDelete ($ storageFile ['id ' ], $ output );
172
167
}
173
168
174
169
return $ queued ;
@@ -177,6 +172,7 @@ private function queueDeletes($type, $deleteInterval, $limit, OutputInterface $o
177
172
/**
178
173
* @param int $storageFileId
179
174
* @param OutputInterface $output
175
+ * @return int The number of storage files deleted
180
176
*/
181
177
private function executeDelete ($ storageFileId , OutputInterface $ output )
182
178
{
@@ -189,7 +185,13 @@ private function executeDelete($storageFileId, OutputInterface $output)
189
185
$ task ->arguments (sprintf ('%d ' , $ storageFileId ));
190
186
$ taskManager ->queueTask ($ task );
191
187
192
- return ;
188
+ if ($ taskManager ->hasQueuedTask ($ task )) {
189
+ $ output ->writeln (sprintf ('Delete already queued for storage file %s... skipping ' , $ storageFileId ));
190
+
191
+ return 0 ;
192
+ }
193
+
194
+ return 1 ;
193
195
}
194
196
195
197
// Execute the delete command directly
@@ -201,12 +203,15 @@ private function executeDelete($storageFileId, OutputInterface $output)
201
203
];
202
204
203
205
$ command ->run (new ArrayInput ($ arguments ), $ output );
206
+
207
+ return 1 ;
204
208
}
205
209
206
210
/**
207
211
* @param int $storageFileId
208
212
* @param Storage $toStorage
209
213
* @param OutputInterface $output
214
+ * @return int The number of storage files that were moved
210
215
*/
211
216
private function executeMove ($ storageFileId , Storage $ toStorage , OutputInterface $ output )
212
217
{
@@ -218,9 +223,15 @@ private function executeMove($storageFileId, Storage $toStorage, OutputInterface
218
223
$ task ->command ('storage:move-file ' );
219
224
$ task ->arguments (sprintf ('%d %d ' , $ storageFileId , $ toStorage ->getId ()));
220
225
$ task ->timeout (300 )->idleTimeout (300 );
226
+
227
+ if ($ taskManager ->hasQueuedTask ($ task )) {
228
+ $ output ->writeln (sprintf ('Move already queued for storage file %s... skipping ' , $ storageFileId ));
229
+
230
+ return 0 ;
231
+ }
221
232
$ taskManager ->queueTask ($ task );
222
233
223
- return ;
234
+ return 1 ;
224
235
}
225
236
226
237
// Execute the move command directly
@@ -233,5 +244,7 @@ private function executeMove($storageFileId, Storage $toStorage, OutputInterface
233
244
];
234
245
235
246
$ command ->run (new ArrayInput ($ arguments ), $ output );
247
+
248
+ return 1 ;
236
249
}
237
250
}
0 commit comments