Will print '.' for each file, except for deleted ones which are marked as 'x'. END_OF_HELP; require_once INSTALLDIR . '/scripts/commandline.inc'; if (!have_option('y', 'yes')) { print "About to delete local file entries where the file cannot be found. Are you sure? [y/N] "; $response = fgets(STDIN); if (strtolower(trim($response)) != 'y') { print "Aborting.\n"; exit(0); } } print "Deleting"; $file = new File(); $file->whereAdd('filename IS NOT NULL'); // local files $file->whereAdd('filehash IS NULL', 'AND'); // without filehash value if ($file->find()) { while ($file->fetch()) { try { $file->getPath(); print '.'; } catch (FileNotFoundException $e) { $file->delete(); print 'x'; } } } print "\nDONE.\n";
function setFilehashOnLocalFiles() { printfnq('Ensuring all local files have the filehash field set...'); $file = new File(); $file->whereAdd('filename IS NOT NULL'); // local files $file->whereAdd('filehash IS NULL', 'AND'); // without filehash value if ($file->find()) { while ($file->fetch()) { try { $orig = clone $file; $file->filehash = hash_file(File::FILEHASH_ALG, $file->getPath()); $file->update($orig); } catch (FileNotFoundException $e) { echo "\n WARNING: file ID {$file->id} does not exist on path '{$e->path}'. If there is no file system error, run: php scripts/clean_file_table.php"; } } } printfnq("DONE.\n"); }