diff --git a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy index 499082d..0967387 100644 --- a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy +++ b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy @@ -290,8 +290,9 @@ Configuration: public MediaLibrary scanMediaLibrary() { status.text = "Scanning media library..." - library.rescanLibrary() - status.text = "Scanned ? files." + def counts = library.rescanLibrary() + status.text = "Scanned ${counts.total} files. " + + "Added ${counts.new} and ignored ${counts.ignored} files." dismissMsgDate = new Date(new Date().time + msgTimeout) return library } diff --git a/core/src/main/groovy/com/jdbernard/wdiwtlt/MediaLibrary.groovy b/core/src/main/groovy/com/jdbernard/wdiwtlt/MediaLibrary.groovy index 7fbcd45..6c064b3 100644 --- a/core/src/main/groovy/com/jdbernard/wdiwtlt/MediaLibrary.groovy +++ b/core/src/main/groovy/com/jdbernard/wdiwtlt/MediaLibrary.groovy @@ -35,7 +35,20 @@ public class MediaLibrary { orm.removeEmptyPlaylists() } - public void rescanLibrary() { libraryRoot.eachFileRecurse { addFile(it) } } + public def rescanLibrary() { + def results = [ total: 0, ignored: 0, new: 0] + + Date startDate = new Date() + libraryRoot.eachFileRecurse { file -> + + if (!file.isFile()) return + def mf = addFile(file) + + results.total++ + if (!mf) results.ignored++ + else if (mf.dateAdded > startDate) results.new++ } + + return results } public MediaFile addFile(File f) { if (!f.exists() || !f.isFile()) { @@ -56,9 +69,9 @@ public class MediaLibrary { try { af = AudioFileIO.read(f) } catch (Exception e) { - logger.info("Ignoring a file because I can't" + - "read the media tag info:\n\t{}", - e.localizedMessage) + logger.info("Ignoring a file because I can't " + + "read the media tag info:\n\t{}\n\t{}", + f.canonicalPath, e.localizedMessage) return null } def fileTag = af.tag