MediaLibrary scan now reports file counts for its scan.
This commit is contained in:
parent
ca682625dc
commit
1e03063400
@ -290,8 +290,9 @@ Configuration:
|
|||||||
|
|
||||||
public MediaLibrary scanMediaLibrary() {
|
public MediaLibrary scanMediaLibrary() {
|
||||||
status.text = "Scanning media library..."
|
status.text = "Scanning media library..."
|
||||||
library.rescanLibrary()
|
def counts = library.rescanLibrary()
|
||||||
status.text = "Scanned ? files."
|
status.text = "Scanned ${counts.total} files. " +
|
||||||
|
"Added ${counts.new} and ignored ${counts.ignored} files."
|
||||||
dismissMsgDate = new Date(new Date().time + msgTimeout)
|
dismissMsgDate = new Date(new Date().time + msgTimeout)
|
||||||
return library }
|
return library }
|
||||||
|
|
||||||
|
@ -35,7 +35,20 @@ public class MediaLibrary {
|
|||||||
orm.removeEmptyPlaylists()
|
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) {
|
public MediaFile addFile(File f) {
|
||||||
if (!f.exists() || !f.isFile()) {
|
if (!f.exists() || !f.isFile()) {
|
||||||
@ -56,9 +69,9 @@ public class MediaLibrary {
|
|||||||
|
|
||||||
try { af = AudioFileIO.read(f) }
|
try { af = AudioFileIO.read(f) }
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logger.info("Ignoring a file because I can't" +
|
logger.info("Ignoring a file because I can't " +
|
||||||
"read the media tag info:\n\t{}",
|
"read the media tag info:\n\t{}\n\t{}",
|
||||||
e.localizedMessage)
|
f.canonicalPath, e.localizedMessage)
|
||||||
return null }
|
return null }
|
||||||
|
|
||||||
def fileTag = af.tag
|
def fileTag = af.tag
|
||||||
|
Loading…
Reference in New Issue
Block a user