fix bug of not cleaning up gravity correctly

This commit is contained in:
Lukas Heiligenbrunner 2020-10-06 01:26:26 +02:00
parent d799cdd610
commit 6076512dd0
2 changed files with 12 additions and 8 deletions

View File

@ -311,15 +311,19 @@ class VideoParser {
$result = $this->conn->query($query); $result = $this->conn->query($query);
while ($r = mysqli_fetch_assoc($result)) { while ($r = mysqli_fetch_assoc($result)) {
if (!file_exists("../" . $r['movie_url'])) { $movie_id = $r['movie_id'];
$query = "SET foreign_key_checks = 0; DELETE FROM videos WHERE movie_id='" . $r['movie_id'] . "'"; $url = $r['movie_url'];
// todo ORDER BY movie_url and erase duplicates also
if (!file_exists("../$url")) {
$query = "DELETE FROM videos WHERE movie_id=$movie_id";
if ($this->conn->query($query) === TRUE) { if ($this->conn->query($query) === TRUE) {
echo('successfully deleted ' . $r['movie_url'] . " from video gravity\n"); echo("successfully deleted $url from video gravity\n");
$this->writeLog('successfully deleted ' . $r['movie_url'] . " from video gravity\n"); $this->writeLog("successfully deleted $url from video gravity\n");
$this->deleted++; $this->deleted++;
} else { } else {
echo "failed to delete " . $r['movie_url'] . " from gravity: " . $this->conn->error . "\n"; echo "failed to delete $url from gravity: $this->conn->error \n";
$this->writeLog("failed to delete " . $r['movie_url'] . " from gravity: " . $this->conn->error . "\n"); $this->writeLog("failed to delete $url from gravity: $this->conn->error \n");
} }
} }
} }

View File

@ -53,9 +53,9 @@ class MovieSettings extends React.Component {
const updateRequest = new FormData(); const updateRequest = new FormData();
// fetch all videos available // fetch all videos available
fetch('/api/extractvideopreviews.php', {method: 'POST', body: updateRequest}) fetch('/api/extractvideopreviews.php', {method: 'POST', body: updateRequest})
.then((response) => response.json() .then((response) => response.text()
.then((result) => { .then((result) => {
// todo 2020-07-4: some kind of start event // todo 2020-07-4: some kind of return finished handler
console.log("returned"); console.log("returned");
})) }))
.catch(() => { .catch(() => {