@@ -541,22 +541,34 @@ public static function purgeTask($taskId, $user) {
541541 throw new HTException ("No access to this task! " );
542542 }
543543 Factory::getAgentFactory ()->getDB ()->beginTransaction ();
544+
545+ // reset all benchmarks on assignments
544546 $ qF = new QueryFilter (Assignment::TASK_ID , $ task ->getId (), "= " );
545547 $ uS = new UpdateSet (Assignment::BENCHMARK , 0 );
546548 Factory::getAssignmentFactory ()->massUpdate ([Factory::FILTER => $ qF , Factory::UPDATE => $ uS ]);
549+
550+ // get all chunk ids of this task
547551 $ chunks = Factory::getChunkFactory ()->filter ([Factory::FILTER => $ qF ]);
548552 $ chunkIds = array ();
549553 foreach ($ chunks as $ chunk ) {
550554 $ chunkIds [] = $ chunk ->getId ();
551555 }
552556 if (sizeof ($ chunkIds ) > 0 ) {
557+ // remove relation of all hashes which were cracked with the chunks which are going to be deleted
553558 $ qF2 = new ContainFilter (Hash::CHUNK_ID , $ chunkIds );
554559 $ uS = new UpdateSet (Hash::CHUNK_ID , null );
555560 Factory::getHashFactory ()->massUpdate ([Factory::FILTER => $ qF2 , Factory::UPDATE => $ uS ]);
556561 Factory::getHashBinaryFactory ()->massUpdate ([Factory::FILTER => $ qF2 , Factory::UPDATE => $ uS ]);
557562 }
563+
564+ // delete all chunks and set keyspace and progress of task to 0
558565 Factory::getChunkFactory ()->massDeletion ([Factory::FILTER => $ qF ]);
559566 Factory::getTaskFactory ()->mset ($ task , [Task::KEYSPACE => 0 , Task::KEYSPACE_PROGRESS => 0 ]);
567+
568+ // set cracked count of taskwrapper to 0
569+ $ taskWrapper ->setCracked (0 );
570+ Factory::getTaskWrapperFactory ()->update ($ taskWrapper );
571+
560572 Factory::getAgentFactory ()->getDB ()->commit ();
561573 }
562574
0 commit comments