@@ -493,8 +493,6 @@ public static function processZap($hashlistId, $separator, $source, $post, $file
493493 $ ll = Factory::getHashlistFactory ()->get ($ l ->getId ());
494494 Factory::getHashlistFactory ()->inc ($ ll , Hashlist::CRACKED , $ crackedIn [$ ll ->getId ()]);
495495 }
496- Factory::getAgentFactory ()->getDB ()->commit ();
497- Factory::getAgentFactory ()->getDB ()->beginTransaction ();
498496 foreach ($ hashlists as $ l ) {
499497 $ crackedIn [$ l ->getId ()] = 0 ;
500498 }
@@ -600,23 +598,8 @@ public static function delete($hashlistId, $user) {
600598 switch ($ hashlist ->getFormat ()) {
601599 case 0 :
602600 $ count = Factory::getHashlistFactory ()->countFilter ([]);
603- if ($ count > 1 ) {
604- $ deleted = 1 ;
605- $ qF = new QueryFilter (Hash::HASHLIST_ID , $ hashlist ->getId (), "= " );
606- $ oF = new OrderFilter (Hash::HASH_ID , "ASC LIMIT 20000 " );
607- while ($ deleted > 0 ) {
608- $ result = Factory::getHashFactory ()->massDeletion ([Factory::FILTER => $ qF , Factory::ORDER => $ oF ]);
609- $ deleted = $ result ->rowCount ();
610- Factory::getAgentFactory ()->getDB ()->commit ();
611- Factory::getAgentFactory ()->getDB ()->beginTransaction ();
612- }
613- }
614- else {
615- // in case there is only one hashlist to delete, truncate the Hash table.
616- Factory::getAgentFactory ()->getDB ()->query ("TRUNCATE TABLE Hash " );
617- // Make sure that a transaction is active, this is what the rest of the function expects.
618- Factory::getAgentFactory ()->getDB ()->beginTransaction ();
619- }
601+ $ qF = new QueryFilter (Hash::HASHLIST_ID , $ hashlist ->getId (), "= " );
602+ Factory::getHashFactory ()->massDeletion ([Factory::FILTER => $ qF ]);
620603 break ;
621604 case 1 :
622605 case 2 :
@@ -801,6 +784,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
801784 }
802785
803786 Factory::getAgentFactory ()->getDB ()->beginTransaction ();
787+
804788 $ hashlist = new Hashlist (null , $ name , $ format , $ hashtype , 0 , $ separator , 0 , $ secret , $ hexsalted , $ salted , $ accessGroup ->getId (), '' , $ brainId , $ brainFeatures , 0 );
805789 $ hashlist = Factory::getHashlistFactory ()->save ($ hashlist );
806790
@@ -835,9 +819,9 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
835819 }
836820 $ file = fopen ($ tmpfile , "rb " );
837821 if (!$ file ) {
822+ Factory::getAgentFactory ()->getDB ()->rollback ();
838823 throw new HttpError ("Failed to open file! " );
839824 }
840- Factory::getAgentFactory ()->getDB ()->commit ();
841825 $ added = 0 ;
842826 $ preFound = 0 ;
843827
@@ -855,7 +839,6 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
855839 $ saltSeparator = "" ;
856840 }
857841 rewind ($ file );
858- Factory::getAgentFactory ()->getDB ()->beginTransaction ();
859842 $ values = array ();
860843 $ bufferCount = 0 ;
861844 while (!feof ($ file )) {
@@ -900,8 +883,6 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
900883 if ($ bufferCount >= 10000 ) {
901884 $ result = Factory::getHashFactory ()->massSave ($ values );
902885 $ added += $ result ->rowCount ();
903- Factory::getAgentFactory ()->getDB ()->commit ();
904- Factory::getAgentFactory ()->getDB ()->beginTransaction ();
905886 $ values = array ();
906887 $ bufferCount = 0 ;
907888 }
@@ -913,7 +894,6 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
913894 fclose ($ file );
914895 unlink ($ tmpfile );
915896 Factory::getHashlistFactory ()->mset ($ hashlist , [Hashlist::HASH_COUNT => $ added , Hashlist::CRACKED => $ preFound ]);
916- Factory::getAgentFactory ()->getDB ()->commit ();
917897 Util::createLogEntry ("User " , $ user ->getId (), DLogEntry::INFO , "New Hashlist created: " . $ hashlist ->getHashlistName ());
918898
919899 NotificationHandler::checkNotifications (DNotificationType::NEW_HASHLIST , new DataSet (array (DPayloadKeys::HASHLIST => $ hashlist )));
@@ -1003,6 +983,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted,
1003983 NotificationHandler::checkNotifications (DNotificationType::NEW_HASHLIST , new DataSet (array (DPayloadKeys::HASHLIST => $ hashlist )));
1004984 break ;
1005985 }
986+ Factory::getAgentFactory ()->getDB ()->commit ();
1006987 return $ hashlist ;
1007988 }
1008989
0 commit comments