@@ -86,8 +86,6 @@ sub scheduleRegisterLibraries {
8686 }
8787
8888 registerLibraries();
89-
90- Slim::Control::Request::executeRequest( undef , [ ' rescan' ] );
9189}
9290
9391sub registerLibraries {
@@ -112,6 +110,8 @@ sub registerLibraries {
112110 $log -> info(" Registered library $newID " );
113111 }
114112 }
113+
114+ Slim::Control::Request::executeRequest( undef , [ ' rescan' ] );
115115}
116116
117117sub getDisplayName {
@@ -124,15 +124,19 @@ sub createLibrary {
124124
125125 $log -> info(" Building library id " . $id . " for name " . $libName );
126126
127+ return if ! main::SCANNER;
128+
129+ $log -> info(" Continuing" );
130+
127131 my $dbh = Slim::Schema-> dbh;
128-
132+
129133 # prepare the insert SQL statement - no need to re-initialize for every track
130134 my $sth_insert = $dbh -> prepare(' INSERT OR IGNORE INTO library_track (library, track) values (?, ?)' );
131135
132136 # get track ID and URL for every single audio track in our library
133137 my $sth = $dbh -> prepare(' SELECT id, url FROM tracks WHERE content_type NOT IN ("cpl", "src", "ssp", "dir") ORDER BY url' );
134138 $sth -> execute();
135-
139+
136140 # use a hash to cache results of the library file checks
137141 my %knownDirs ;
138142
@@ -144,22 +148,22 @@ sub createLibrary {
144148
145149 # check the list of dirs we've seen before first
146150 my $hasLibFile = $knownDirs {$key };
147-
151+
148152 # only check the library files if we don't have a defined result for this folder
149153 if (!defined $hasLibFile ) {
150154 my $dir = dirname(Slim::Utils::Misc::pathFromFileURL($url ));
151155
152156 my $libFile = catfile($dir , " simple-library-views-$libName " );
153157 my $newLibFile = catfile($dir , " .simple-library-views-$libName " );
154-
158+
155159 $hasLibFile = $knownDirs {$key } = (-f $libFile || -f $newLibFile ) ? 1 : 0;
156160 }
157161
158162 main::DEBUGLOG && $log -> is_debug && $log -> debug(" ID: " . $trackid . " , URL: " . $url . " , path: " . $url );
159163
160164 if ($hasLibFile ) {
161165 $log -> debug(" Adding " . $url . " to library " . $libName );
162-
166+
163167 $sth_insert -> execute($id , $trackid );
164168 }
165169 }
0 commit comments