--- linuxsampler/trunk/src/db/InstrumentsDbUtilities.cpp 2007/05/24 14:04:18 1200 +++ linuxsampler/trunk/src/db/InstrumentsDbUtilities.cpp 2007/09/13 21:46:25 1345 @@ -254,7 +254,7 @@ if(Path.compare("/") != 0) s += "/"; int res = sqlite3_step(pStmt); while(res == SQLITE_ROW) { - pDirectories->push_back(s + ToString(sqlite3_column_text(pStmt, 0))); + pDirectories->push_back(s + idb->toAbstractName(ToString(sqlite3_column_text(pStmt, 0)))); res = sqlite3_step(pStmt); } @@ -339,7 +339,7 @@ if(Path.compare("/") != 0) s += "/"; int res = sqlite3_step(pStmt); while(res == SQLITE_ROW) { - pInstruments->push_back(s + ToString(sqlite3_column_text(pStmt, 0))); + pInstruments->push_back(s + idb->toAbstractName(ToString(sqlite3_column_text(pStmt, 0)))); res = sqlite3_step(pStmt); } @@ -391,7 +391,9 @@ } int dstDirId = db->GetDirectoryId(dir); - if(dstDirId == -1) throw Exception("Unkown DB directory: " + dir); + if(dstDirId == -1) { + throw Exception("Unkown DB directory: " + InstrumentsDb::toEscapedPath(dir)); + } IntListPtr ids = db->GetInstrumentIDs(DirId); for (int i = 0; i < ids->size(); i++) { String name = db->GetInstrumentName(ids->at(i)); @@ -488,6 +490,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 +521,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 +552,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 +616,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 +657,7 @@ String s = fpath; if(s.length() < 4) return 0; if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) FileCount++; + return 0; };