From 6076512dd0c4654307746063e2455c717669ea3b Mon Sep 17 00:00:00 2001 From: Lukas Heiligenbrunner Date: Tue, 6 Oct 2020 01:26:26 +0200 Subject: [PATCH] fix bug of not cleaning up gravity correctly --- api/src/VideoParser.php | 16 ++++++++++------ src/pages/SettingsPage/MovieSettings.js | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api/src/VideoParser.php b/api/src/VideoParser.php index f09aed9..b6bff1d 100644 --- a/api/src/VideoParser.php +++ b/api/src/VideoParser.php @@ -311,15 +311,19 @@ class VideoParser { $result = $this->conn->query($query); while ($r = mysqli_fetch_assoc($result)) { - if (!file_exists("../" . $r['movie_url'])) { - $query = "SET foreign_key_checks = 0; DELETE FROM videos WHERE movie_id='" . $r['movie_id'] . "'"; + $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) { - echo('successfully deleted ' . $r['movie_url'] . " from video gravity\n"); - $this->writeLog('successfully deleted ' . $r['movie_url'] . " from video gravity\n"); + echo("successfully deleted $url from video gravity\n"); + $this->writeLog("successfully deleted $url from video gravity\n"); $this->deleted++; } else { - echo "failed to delete " . $r['movie_url'] . " from gravity: " . $this->conn->error . "\n"; - $this->writeLog("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 $url from gravity: $this->conn->error \n"); } } } diff --git a/src/pages/SettingsPage/MovieSettings.js b/src/pages/SettingsPage/MovieSettings.js index 5964252..7a1c265 100644 --- a/src/pages/SettingsPage/MovieSettings.js +++ b/src/pages/SettingsPage/MovieSettings.js @@ -53,9 +53,9 @@ class MovieSettings extends React.Component { const updateRequest = new FormData(); // fetch all videos available fetch('/api/extractvideopreviews.php', {method: 'POST', body: updateRequest}) - .then((response) => response.json() + .then((response) => response.text() .then((result) => { - // todo 2020-07-4: some kind of start event + // todo 2020-07-4: some kind of return finished handler console.log("returned"); })) .catch(() => {