Search in sources :

Example 1 with LibraryScanner

use of com.github.hakko.musiccabinet.io.LibraryScanner in project musiccabinet by hakko.

the class LibraryScannerService method update.

public void update(Set<String> paths, boolean isRootPaths) throws ApplicationException {
    isLibraryBeingScanned = true;
    try {
        clearImport();
        startReceivingServices();
        Set<String> rootPaths = getRootPaths(paths);
        for (String path : rootPaths) {
            Files.walkFileTree(Paths.get(path), new LibraryScanner(libraryPresenceChannel));
        }
        if (isRootPaths) {
            libraryPresenceChannel.send(msg(null, rootPaths, new HashSet<File>()));
        }
        libraryPresenceChannel.send(FINISHED_MESSAGE);
        workerThreads.await();
        updateLibrary();
    } catch (IOException | InterruptedException e) {
        throw new ApplicationException("Scanning aborted due to error!", e);
    }
    isLibraryBeingScanned = false;
}
Also used : ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) LibraryScanner(com.github.hakko.musiccabinet.io.LibraryScanner) IOException(java.io.IOException) HashSet(java.util.HashSet)

Aggregations

ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)1 LibraryScanner (com.github.hakko.musiccabinet.io.LibraryScanner)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1