@@ -826,6 +826,46 @@ private function clean()
826826        $ response  = curl_exec ($ ch );
827827        curl_close ($ ch );
828828
829+         $ ch  = curl_init ($ host ."/_snapshot/_all " );
830+         curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
831+         curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , "GET " );
832+         curl_setopt ($ ch , CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_0 );
833+ 
834+         $ response  = curl_exec ($ ch );
835+         curl_close ($ ch );
836+         if  ($ response  != "{} " ) {
837+             $ response  = json_decode ($ response , true );
838+             foreach  ($ response  as  $ repo  => $ settings ) {
839+                 if  ($ settings ['type ' ] == 'fs ' ) {
840+                     $ ch  = curl_init ($ host ."/_snapshot/ $ repo/_all?ignore_unavailable " );
841+                     curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
842+                     curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , "GET " );
843+                     curl_setopt ($ ch , CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_0 );
844+ 
845+                     $ snapshots  = json_decode (curl_exec ($ ch ), true );
846+                     curl_close ($ ch );
847+                     foreach  ($ snapshots ['snapshots ' ] as  $ snapshot ) {
848+                         $ snapshotName  = $ snapshot ['snapshot ' ];
849+                         $ ch  = curl_init ($ host ."/_snapshot/ $ repo/ $ snapshotName " );
850+                         curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
851+                         curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , "DELETE " );
852+                         curl_setopt ($ ch , CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_0 );
853+ 
854+                         $ response  = curl_exec ($ ch );
855+                         curl_close ($ ch );
856+                     }
857+                     $ ch  = curl_init ($ host ."/_snapshot/ $ repo " );
858+                     curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
859+                     curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , "DELETE " );
860+                     curl_setopt ($ ch , CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_0 );
861+ 
862+                     $ response  = curl_exec ($ ch );
863+                     curl_close ($ ch );
864+ 
865+                 }
866+             }
867+         }
868+ 
829869        // TODO ewwww... 
830870        shell_exec ('rm -rf /tmp/test_repo_create_1_loc ' );
831871        shell_exec ('rm -rf /tmp/test_repo_restore_1_loc ' );
0 commit comments