From 2d20656e220359e224cc0a7ef255cf0e02a1bc8f Mon Sep 17 00:00:00 2001
From: Diogo Cordeiro <diogo@fc.up.pt>
Date: Thu, 18 Apr 2019 01:03:09 +0100
Subject: [PATCH] [StoreRemoteMedia] script removeRemoteMedia.php was trying to
 remove already removed files Sometimes different posts are associated with
 the same file, that case wasn't considered Thanks to XRevan86 for spotting
 this issue.

---
 plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php b/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php
index b3b43018a9..2a5bdebd46 100755
--- a/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php
+++ b/plugins/StoreRemoteMedia/scripts/removeRemoteMedia.php
@@ -30,7 +30,7 @@
 define('INSTALLDIR', realpath(__DIR__ . '/../../..'));
 
 $shortoptions = 'l::a::i';
-$longoptions = ['limit=','all','image'];
+$longoptions = ['limit=', 'all', 'image'];
 
 $helptext = <<<END_OF_HELP
 remove_remote_media.php [options]
@@ -43,7 +43,7 @@ In case the attachment is an image its thumbs will be removed as well.
 
 END_OF_HELP;
 
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR . '/scripts/commandline.inc';
 
 $quiet = have_option('q', 'quiet');
 $include_previews = have_option('a', 'all');
@@ -61,7 +61,7 @@ if (empty($max_date)) {
 }
 
 $query = "
-    SELECT
+    SELECT DISTINCT
         file_to_post.file_id
     FROM
         file_to_post
-- 
2.39.5