Skip to content

Commit

Permalink
Web|Builder: Fixed purging of old builds and files
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 2, 2017
1 parent 396c1cb commit 792d569
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions webapi/1/admin/bdb.php
Expand Up @@ -17,7 +17,7 @@
* http://www.gnu.org/licenses/gpl.html
*/

require_once(__DIR__.'/../database.inc.php');
require_once(__DIR__.'/../builds.inc.php');

function add_build($json_args)
{
Expand Down Expand Up @@ -117,22 +117,22 @@ function purge_old_builds()
$file_paths = [];
while ($row = $result->fetch_assoc()) {
$build = $row['build'];
echo("Purging build $build...");
echo("Purging build $build...\n");
if ($builds_sql) $builds_sql .= " OR ";
$builds_sql .= "build=$build";
foreach (db_build_list_files($db, $build) as $file) {
$file_paths[] = db_file_path($db, file);
$file_paths[] = db_file_path($db, $file);
}
}
if ($builds_sql) {
if (!empty($builds_sql)) {
db_query($db, "DELETE FROM ".DB_TABLE_BUILDS." WHERE $builds_sql");
db_query($db, "DELETE FROM ".DB_TABLE_FILES ." WHERE $builds_sql");
}
$db->close();

// Remove the files, too.
foreach ($file_paths as $path) {
echo("Deleting: $path");
echo("Deleting: $path\n");
unlink($path);
}
}
Expand Down

0 comments on commit 792d569

Please sign in to comment.