forked from GNUsocial/gnu-social
Haha, it essentially became a NOOP with the last commit
This commit is contained in:
parent
6f2fbd448d
commit
2198f39597
@ -39,16 +39,22 @@ require_once INSTALLDIR.'/scripts/commandline.inc';
|
|||||||
|
|
||||||
print "Finding File entries that are not related to a Notice (or the notice has been deleted)...";
|
print "Finding File entries that are not related to a Notice (or the notice has been deleted)...";
|
||||||
$file = new File();
|
$file = new File();
|
||||||
$sql = 'SELECT id FROM file'.
|
$sql = 'SELECT file.id FROM file'.
|
||||||
' JOIN file_to_post ON file_to_post.file_id=file.id'.
|
' JOIN file_to_post ON file_to_post.file_id=file.id'.
|
||||||
' WHERE'.
|
' WHERE'.
|
||||||
' NOT EXISTS (SELECT file_to_post.file_id FROM file_to_post WHERE file.id=file_id)'.
|
' NOT EXISTS (SELECT file_to_post.file_id FROM file_to_post WHERE file.id=file_to_post.file_id)'.
|
||||||
' OR NOT EXISTS (SELECT notice.id FROM notice WHERE notice.id=post_id);';
|
' OR NOT EXISTS (SELECT notice.id FROM notice WHERE notice.id=file_to_post.post_id);';
|
||||||
|
|
||||||
print " {$file->N} found.\n";
|
if ($file->query($sql) !== false) {
|
||||||
if ($file->N == 0) {
|
print " {$file->N} found.\n";
|
||||||
exit(0);
|
if ($file->N == 0) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "FAILED";
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!have_option('y', 'yes')) {
|
if (!have_option('y', 'yes')) {
|
||||||
print "About to delete the entries along with locally stored files. Are you sure? [y/N] ";
|
print "About to delete the entries along with locally stored files. Are you sure? [y/N] ";
|
||||||
$response = fgets(STDIN);
|
$response = fgets(STDIN);
|
||||||
@ -57,18 +63,17 @@ if (!have_option('y', 'yes')) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($file->query($sql) !== false) {
|
|
||||||
print "\nDeleting: ";
|
print "\nDeleting: ";
|
||||||
while ($file->fetch()) {
|
while ($file->fetch()) {
|
||||||
try {
|
try {
|
||||||
$file->getPath();
|
$file->getPath();
|
||||||
$file->delete();
|
$file->delete();
|
||||||
print 'x';
|
print 'x';
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// either FileNotFound exception or ClientException
|
// either FileNotFound exception or ClientException
|
||||||
$file->delete();
|
$file->delete();
|
||||||
print '.';
|
print '.';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "\nDONE.\n";
|
print "\nDONE.\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user