aboutsummaryrefslogtreecommitdiff
path: root/utils/remove.php
blob: 289a617af50a045ea14000a45ee6e0dfa7be3643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env php
<?php
/*
 * Remove one build failure from the database
 */

include(dirname(__FILE__) . "/../web/funcs.inc.php");

if (count($argv) != 2) {
  echo "Wrong number of arguments\n";
  exit(1);
}

$hash = $argv[1];

$db = new db();

echo "Getting id from results...";

$sql = "select id from results where identifier='" . $hash . "'";
$ret = $db->query($sql);
if ($ret == FALSE) {
  echo "FAILED\n";
  exit(1);
}
if (mysqli_num_rows($ret) != 1) {
  echo "NOT FOUND\n";
  exit(1);
}

$c = mysqli_fetch_object($ret);
$id = $c->id;

echo " $id\n";

$path = $maindir . "/results/" . substr($hash, 0, 3) . "/" . $hash;

if (!is_writable($path)) {
  echo "ERROR: you don't have write permission on the result directory\n";
  exit(1);
}

echo "Removing from results_config...";

$sql = "delete from symbol_per_result where result_id=" . $id;
$ret = $db->query($sql);
if ($ret == FALSE) {
  echo "FAILED\n";
  exit(1);
}
echo "DONE\n";

echo "Removing from results...";

$sql = "delete from results where id=" . $id;
$ret = $db->query($sql);
if ($ret == FALSE) {
  echo "FAILED\n";
  exit(1);
}
echo "DONE\n";

echo "Removing build results...";
system("rm -rf " . $path);
echo "DONE\n";

?>