/** * Check if a media file is new or changed. * A file is considered existing and unchanged only when: * - its hash (ID) can be found in the database, and * - its last modified time is the same with that of the comparing file. * * @param SplFileInfo $file * * @return bool */ protected function isNewOrChanged(SplFileInfo $file) { return !Song::whereIdAndMtime($this->getHash($file->getPathname()), $file->getMTime())->count(); }