@@ -69,6 +69,56 @@ public function indexAction($auth_key, $version)
69
69
}
70
70
}
71
71
72
+ public function deleteAllObjectsAction ($ auth_key )
73
+ {
74
+ if ($ this ->container ->getParameter ('auth_key ' ) != $ auth_key )
75
+ return new Response (json_encode (array ("success " => false , "step " => 0 , "message " => "Invalid authorization key. " )));
76
+
77
+ $ tempDir = $ this ->container ->getParameter ('temp_dir ' );
78
+ $ objectFilesDir = $ this ->container ->getParameter ('objdir ' );
79
+ $ fileCount = 0 ;
80
+ $ undeletedFiles = "" ;
81
+ $ deletionStats = array ("success_dot_a " => 0 ,
82
+ "failure_dot_a " => 0 ,
83
+ "success_dot_o " => 0 ,
84
+ "failure_dot_o " => 0 ,
85
+ "success_dot_d " => 0 ,
86
+ "failure_dot_d " => 0 ,
87
+ "success_dot_LOCK " => 0 ,
88
+ "failure_dot_LOCK " => 0 );
89
+
90
+ if ($ handle = opendir ("$ tempDir/ $ objectFilesDir " ))
91
+ {
92
+
93
+ while (false !== ($ entry = readdir ($ handle )))
94
+ {
95
+ if ($ entry != ". " && $ entry != ".. " && $ entry != ".DS_Store " )
96
+ {
97
+ $ fileCount ++;
98
+ $ extension = pathinfo ($ entry , PATHINFO_EXTENSION );
99
+
100
+ if (!in_array ($ extension , array ("a " , "o " , "d " , "LOCK " )))
101
+ continue ;
102
+
103
+ if (@unlink ("$ tempDir/ $ objectFilesDir/ $ entry " ) === false )
104
+ {
105
+ $ deletionStats ["failure_dot_ $ extension " ]++;
106
+ $ undeletedFiles .= $ entry . "\n" ;
107
+ }
108
+ else
109
+ $ deletionStats ["success_dot_ $ extension " ]++;
110
+ }
111
+ }
112
+ closedir ($ handle );
113
+ }else
114
+ return new Response (json_encode (array ("success " => false , "step " => 0 , "message " => "Failed to access object files directory. " )));
115
+
116
+ return new Response (json_encode (array_merge (array ("success " => true ,
117
+ "message " => "Object files deletion complete. Found $ fileCount files. " ),
118
+ $ deletionStats ,
119
+ array ("Files not deleted " => $ undeletedFiles ))));
120
+ }
121
+
72
122
/**
73
123
\brief Creates a list of the configuration parameters to be used in the compilation process.
74
124
0 commit comments