This repository was archived by the owner on Mar 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,11 @@ public function encode() {
9999 $ zip ->close ();
100100
101101 $ profile = base64_encode (file_get_contents ($ temp_zip ));
102+
103+ // clean up
104+ $ this ->deleteDirectory ($ temp_dir );
105+ unlink ($ temp_zip );
106+
102107 return $ profile ;
103108 }
104109
@@ -123,6 +128,10 @@ private function installExtension($extension, $profile_dir) {
123128 mkdir ($ ext_dir , 0777 , true );
124129
125130 $ this ->extractTo ($ extension , $ ext_dir );
131+
132+ // clean up
133+ $ this ->deleteDirectory ($ temp_dir );
134+
126135 return $ ext_dir ;
127136 }
128137
@@ -144,6 +153,24 @@ private function createTempDirectory($prefix = '') {
144153 return $ temp_dir ;
145154 }
146155
156+ /**
157+ * @param string $directory The path to the directory.
158+ */
159+ private function deleteDirectory ($ directory ) {
160+ $ dir = new RecursiveDirectoryIterator ($ directory , FilesystemIterator::SKIP_DOTS );
161+ $ paths = new RecursiveIteratorIterator ($ dir , RecursiveIteratorIterator::CHILD_FIRST );
162+
163+ foreach ($ paths as $ path ) {
164+ if ($ path ->isDir () && !$ path ->isLink ()) {
165+ rmdir ($ path ->getPathname ());
166+ } else {
167+ unlink ($ path ->getPathname ());
168+ }
169+ }
170+
171+ rmdir ($ directory );
172+ }
173+
147174 /**
148175 * @param string $xpi The path to the .xpi extension.
149176 * @param string $target_dir The path to the unzip directory.
You can’t perform that action at this time.
0 commit comments