--- linuxsampler/trunk/src/db/InstrumentsDbUtilities.cpp 2007/05/26 13:59:40 1207 +++ linuxsampler/trunk/src/db/InstrumentsDbUtilities.cpp 2007/05/26 22:20:46 1208 @@ -488,6 +488,12 @@ default: throw Exception("Unknown scan mode"); } + + // Just to be sure that the frontends will be notified about the job completion + if (Progress.GetTotalFileCount() != Progress.GetScannedFileCount()) { + Progress.SetTotalFileCount(Progress.GetScannedFileCount()); + } + if (Progress.GetStatus() != 100) Progress.SetStatus(100); } catch(Exception e) { Progress.SetErrorStatus(-1); throw e; @@ -513,7 +519,13 @@ continue; } - count++; + String s(pEnt->d_name); + if(s.length() < 4) { + pEnt = readdir(pDir); + continue; + } + if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) count++; + pEnt = readdir(pDir); } @@ -538,7 +550,18 @@ } void AddInstrumentsFromFileJob::Run() { - InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index, &Progress); + try { + InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index, &Progress); + + // Just to be sure that the frontends will be notified about the job completion + if (Progress.GetTotalFileCount() != Progress.GetScannedFileCount()) { + Progress.SetTotalFileCount(Progress.GetScannedFileCount()); + } + if (Progress.GetStatus() != 100) Progress.SetStatus(100); + } catch(Exception e) { + Progress.SetErrorStatus(-1); + throw e; + } } @@ -591,13 +614,19 @@ } InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); - if (!db->DirectoryExist(dir)) db->AddDirectory(dir); - db->AddInstrumentsNonrecursive(dir, String(fpath), pProgress); + if (HasInstrumentFiles(String(fpath))) { + if (!db->DirectoryExist(dir)) db->AddDirectory(dir); + db->AddInstrumentsNonrecursive(dir, String(fpath), pProgress); + } return 0; }; + bool DirectoryScanner::HasInstrumentFiles(String Dir) { + return InstrumentFileCounter::Count(Dir) > 0; + } + int InstrumentFileCounter::FileCount; int InstrumentFileCounter::Count(String FsDir) { @@ -626,6 +655,7 @@ String s = fpath; if(s.length() < 4) return 0; if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) FileCount++; + return 0; };