MediaLibrary scan now reports file counts for its scan.

This commit is contained in:
Jonathan Bernard 2016-03-10 10:46:01 -06:00
parent ca682625dc
commit 1e03063400
2 changed files with 20 additions and 6 deletions

View File

@ -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 }

View File

@ -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()) {
@ -57,8 +70,8 @@ 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)
"read the media tag info:\n\t{}\n\t{}",
f.canonicalPath, e.localizedMessage)
return null }
def fileTag = af.tag