mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
Altered the folder-table to exclude the syncpath. *YOU NEED TO DELETE YOUR OLD DATABASE*
This commit is contained in:
parent
817fdad434
commit
f9de0cf101
@ -41,7 +41,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../;../../3rdparty/include/;"taglib-1.5";"taglib-1.5/taglib";"taglib-1.5/taglib/ape";"taglib-1.5/taglib/flac";"taglib-1.5/taglib/mpc";"taglib-1.5/taglib/mpeg";"taglib-1.5/taglib/mpeg/id3v1";"taglib-1.5/taglib/mpeg/id3v2";"taglib-1.5/taglib/mpeg/id3v2/frames";"taglib-1.5/taglib/ogg";"taglib-1.5/taglib/ogg/flac";"taglib-1.5/taglib/ogg/speex";"taglib-1.5/taglib/ogg/vorbis";"taglib-1.5/taglib/toolkit";"taglib-1.5/taglib/trueaudio";"taglib-1.5/taglib/wavpack""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MUSIKCOREIMPORT"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
@ -125,7 +125,7 @@
|
||||
InlineFunctionExpansion="2"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="../../;../../3rdparty/include/;"taglib-1.5";"taglib-1.5/taglib";"taglib-1.5/taglib/ape";"taglib-1.5/taglib/flac";"taglib-1.5/taglib/mpc";"taglib-1.5/taglib/mpeg";"taglib-1.5/taglib/mpeg/id3v1";"taglib-1.5/taglib/mpeg/id3v2";"taglib-1.5/taglib/mpeg/id3v2/frames";"taglib-1.5/taglib/ogg";"taglib-1.5/taglib/ogg/flac";"taglib-1.5/taglib/ogg/speex";"taglib-1.5/taglib/ogg/vorbis";"taglib-1.5/taglib/toolkit";"taglib-1.5/taglib/trueaudio";"taglib-1.5/taglib/wavpack""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MUSIKCOREIMPORT"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="0"
|
||||
|
@ -223,7 +223,7 @@ void Indexer::Synchronize(){
|
||||
utfstring sPath = aPaths[i];
|
||||
DBINT iPathId = aPathIds[i];
|
||||
|
||||
this->SyncDirectory(sPath,0,iPathId);
|
||||
this->SyncDirectory(sPath,0,iPathId,sPath);
|
||||
}
|
||||
|
||||
{
|
||||
@ -312,7 +312,7 @@ void Indexer::CountFiles(utfstring &sFolder){
|
||||
///
|
||||
///Read all tracks in a folder. All folders in that folder is recursively called.
|
||||
//////////////////////////////////////////
|
||||
void Indexer::SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPathId){
|
||||
void Indexer::SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPathId,utfstring &syncPath){
|
||||
|
||||
if(this->Exited() || this->Restarted()){
|
||||
return;
|
||||
@ -341,11 +341,14 @@ void Indexer::SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPath
|
||||
// If it do not exists, create it
|
||||
if(iFolderId==0){
|
||||
|
||||
db::CachedStatement stmt("INSERT INTO folders (name,path_id,parent_id,fullpath) VALUES(?,?,?,?)",this->dbConnection);
|
||||
// Only save the relative path
|
||||
utfstring relativePath( sFolder.substr(syncPath.size()) );
|
||||
|
||||
db::CachedStatement stmt("INSERT INTO folders (name,path_id,parent_id,relative_path) VALUES(?,?,?,?)",this->dbConnection);
|
||||
stmt.BindTextUTF(0,sFolderLeaf);
|
||||
stmt.BindInt(1,iPathId);
|
||||
stmt.BindInt(2,iParentFolderId);
|
||||
stmt.BindTextUTF(3,sFolder);
|
||||
stmt.BindTextUTF(3,relativePath);
|
||||
|
||||
if(stmt.Step()==db::ReturnCode::Done){
|
||||
iFolderId = this->dbConnection.LastInsertedId();
|
||||
@ -372,7 +375,7 @@ void Indexer::SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPath
|
||||
oDirectory.assign(oFile->path().string());
|
||||
|
||||
// If this is a directory, recurse down
|
||||
this->SyncDirectory(oDirectory,iFolderId,iPathId);
|
||||
this->SyncDirectory(oDirectory,iFolderId,iPathId,syncPath);
|
||||
|
||||
}else{
|
||||
|
||||
@ -440,10 +443,8 @@ void Indexer::ThreadLoop(){
|
||||
|
||||
this->SynchronizeStart();
|
||||
|
||||
int dbCache = prefs.GetInt("DatabaseCache",4096);
|
||||
|
||||
// Database should only be open when synchronizing
|
||||
this->dbConnection.Open(this->database.c_str(),0,dbCache);
|
||||
this->dbConnection.Open(this->database.c_str(),0);
|
||||
this->RestartSync(false);
|
||||
this->Synchronize();
|
||||
this->dbConnection.Close();
|
||||
@ -524,7 +525,7 @@ void Indexer::SyncDelete(std::vector<DBINT> aPaths){
|
||||
|
||||
{
|
||||
// Remove non existing folders
|
||||
db::Statement stmt("SELECT id,fullpath FROM folders WHERE path_id=?",this->dbConnection);
|
||||
db::Statement stmt("SELECT f.id,p.path||f.relative_path FROM folders f,paths p WHERE f.path_id=p.id AND p.id=?",this->dbConnection);
|
||||
db::Statement stmtRemove("DELETE FROM folders WHERE id=?",this->dbConnection);
|
||||
|
||||
for(int i(0);i<aPaths.size();++i){
|
||||
@ -574,7 +575,7 @@ void Indexer::SyncDelete(std::vector<DBINT> aPaths){
|
||||
}
|
||||
|
||||
|
||||
db::Statement stmt("SELECT t.id,f.fullpath||'/'||t.filename FROM tracks t,folders f WHERE t.folder_id=f.id AND f.path_id=?",this->dbConnection);
|
||||
db::Statement stmt("SELECT t.id,p.path||f.relative_path||'/'||t.filename FROM tracks t,folders f,paths p WHERE t.folder_id=f.id AND f.path_id=p.id AND p.id=?",this->dbConnection);
|
||||
db::Statement stmtRemove("DELETE FROM tracks WHERE id=?",this->dbConnection);
|
||||
|
||||
for(int i(0);i<aPaths.size();++i){
|
||||
@ -774,7 +775,7 @@ void Indexer::SyncOptimize(){
|
||||
genre, artist, album, track number, path, filename
|
||||
************************************/
|
||||
|
||||
db::Statement stmt("SELECT t.id FROM tracks t LEFT OUTER JOIN artists ar ON ar.id=t.visual_artist_id LEFT OUTER JOIN albums al ON al.id=t.album_id LEFT OUTER JOIN folders f ON f.id=t.folder_id ORDER BY ar.sort_order,al.sort_order,t.track,f.fullpath,t.filename",this->dbConnection);
|
||||
db::Statement stmt("SELECT t.id FROM tracks t LEFT OUTER JOIN artists ar ON ar.id=t.visual_artist_id LEFT OUTER JOIN albums al ON al.id=t.album_id LEFT OUTER JOIN folders f ON f.id=t.folder_id ORDER BY ar.sort_order,al.sort_order,t.track,f.relative_path,t.filename",this->dbConnection);
|
||||
|
||||
db::Statement stmtUpdate("UPDATE tracks SET sort_order1=? WHERE id=?",this->dbConnection);
|
||||
iCount = 0;
|
||||
|
@ -90,7 +90,7 @@ namespace musik{ namespace core{
|
||||
void CountFiles(utfstring &sFolder);
|
||||
|
||||
void Synchronize();
|
||||
void SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPathId);
|
||||
void SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPathId,utfstring &syncPath);
|
||||
void SyncDelete(std::vector<DBINT> aPaths);
|
||||
void SyncCleanup();
|
||||
void SyncAddRemovePaths();
|
||||
|
@ -547,7 +547,7 @@ void Library::Base::CreateDatabase(db::Connection &db){
|
||||
db.Execute("CREATE TABLE IF NOT EXISTS folders ("
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
"name TEXT default '',"
|
||||
"fullpath TEXT default '',"
|
||||
"relative_path TEXT default '',"
|
||||
"parent_id INTEGER DEFAULT 0,"
|
||||
"path_id INTEGER DEFAULT 0"
|
||||
")");
|
||||
|
@ -77,9 +77,9 @@ void TrackMetadata::CreateSQL(){
|
||||
this->GetFixedTrackMetakeys(std::string("filename"),fields);
|
||||
|
||||
if( (field=fields.find("path"))!=fields.end() ){
|
||||
this->sSQL += ",f.fullpath||'/'||t.filename";
|
||||
this->sSQLTables += ",folders f";
|
||||
this->sSQLWhere += " AND t.folder_id=f.id";
|
||||
this->sSQL += ",p.path||f.relative_path||'/'||t.filename";
|
||||
this->sSQLTables += ",folders f,paths p";
|
||||
this->sSQLWhere += " AND t.folder_id=f.id AND f.path_id=p.id";
|
||||
this->fieldOrder.push_back(*field);
|
||||
fields.erase(field);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
|
||||
PreprocessorDefinitions="BOOST_ALL_NO_LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;XML_STATIC"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;XML_STATIC"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
@ -107,7 +107,7 @@
|
||||
InlineFunctionExpansion="0"
|
||||
FavorSizeOrSpeed="0"
|
||||
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
|
||||
PreprocessorDefinitions="BOOST_ALL_NO_LIB;WIN32;_CRT_SECURE_NO_DEPRECATE;XML_STATIC"
|
||||
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;XML_STATIC"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderThrough="pch.hpp"
|
||||
|
@ -79,7 +79,7 @@ Connection::~Connection(){
|
||||
///Error code returned by SQLite
|
||||
//////////////////////////////////////////
|
||||
int Connection::Open(const utfchar *database,unsigned int options,unsigned int cache){
|
||||
sqlite3_enable_shared_cache(1);
|
||||
// sqlite3_enable_shared_cache(1);
|
||||
|
||||
int error;
|
||||
#ifdef UTF_WIDECHAR
|
||||
@ -179,7 +179,7 @@ int Connection::Execute(const char* sql){
|
||||
|
||||
// Execute the statement
|
||||
int error = sqlite3_step(stmt);
|
||||
if(error==SQLITE_OK || error==SQLITE_DONE){
|
||||
if(error!=SQLITE_OK && error!=SQLITE_DONE){
|
||||
sqlite3_finalize(stmt);
|
||||
return ReturnCode::Error;
|
||||
}
|
||||
@ -207,7 +207,8 @@ int Connection::Execute(const wchar_t* sql){
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->mutex);
|
||||
if(sqlite3_prepare16_v2(this->connection,sql,-1,&stmt,NULL)!=SQLITE_OK){
|
||||
int err = sqlite3_prepare16_v2(this->connection,sql,-1,&stmt,NULL);
|
||||
if(err!=SQLITE_OK){
|
||||
sqlite3_finalize(stmt);
|
||||
return ReturnCode::Error;
|
||||
}
|
||||
@ -215,7 +216,7 @@ int Connection::Execute(const wchar_t* sql){
|
||||
|
||||
// Execute the statement
|
||||
int error = sqlite3_step(stmt);
|
||||
if(error==SQLITE_OK || error==SQLITE_DONE){
|
||||
if(error!=SQLITE_OK && error!=SQLITE_DONE){
|
||||
sqlite3_finalize(stmt);
|
||||
return ReturnCode::Error;
|
||||
}
|
||||
@ -257,16 +258,15 @@ void Connection::Initialize(unsigned int cache){
|
||||
sqlite3_exec(this->connection,"PRAGMA page_size=4096",NULL,NULL,NULL); // According to windows standard page size
|
||||
sqlite3_exec(this->connection,"PRAGMA auto_vacuum=0",NULL,NULL,NULL); // No autovaccum.
|
||||
|
||||
if(cache==0){
|
||||
cache=1024; // Default cache set to 4Mb
|
||||
}else{
|
||||
if(cache!=0){
|
||||
// Divide by 4 to since the page_size is 4096
|
||||
// Total cache is the same as page_size*cache_size
|
||||
cache = cache/4;
|
||||
|
||||
std::string cacheSize("PRAGMA cache_size=" + boost::lexical_cast<std::string>(cache));
|
||||
sqlite3_exec(this->connection,cacheSize.c_str(),NULL,NULL,NULL); // size * 1.5kb = 6Mb cache
|
||||
}
|
||||
|
||||
std::string cacheSize("PRAGMA cache_size=" + boost::lexical_cast<std::string>(cache));
|
||||
sqlite3_exec(this->connection,cacheSize.c_str(),NULL,NULL,NULL); // size * 1.5kb = 6Mb cache
|
||||
|
||||
sqlite3_exec(this->connection,"PRAGMA case_sensitive_like=0",NULL,NULL,NULL); // More speed if case insensitive
|
||||
sqlite3_exec(this->connection,"PRAGMA count_changes=0",NULL,NULL,NULL); // If set it counts changes on SQL UPDATE. More speed when not.
|
||||
@ -298,6 +298,9 @@ sqlite3_stmt *Connection::GetCachedStatement(const char* sql){
|
||||
boost::mutex::scoped_lock lock(this->mutex);
|
||||
|
||||
int err = sqlite3_prepare_v2(this->connection,sql,-1,&newStmt,NULL);
|
||||
if(err!=SQLITE_OK){
|
||||
return NULL;
|
||||
}
|
||||
return newStmt;
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Forward declare
|
||||
struct sqlite3;
|
||||
struct sqlite3_stmt;
|
||||
struct sqlite3;
|
||||
struct sqlite3_stmt;
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -56,6 +56,9 @@ using namespace musik::core::db;
|
||||
Statement::Statement(const char* sql,Connection &connection) : connection(&connection),stmt(NULL){
|
||||
boost::mutex::scoped_lock lock(connection.mutex);
|
||||
int err = sqlite3_prepare_v2(this->connection->connection,sql,-1,&this->stmt,NULL);
|
||||
if(err!=SQLITE_OK){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
|
@ -71,7 +71,7 @@
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
EntryPointSymbol="wWinMainCRTStartup"
|
||||
ImportLibrary="../../bin/$(ConfigurationName)/mC2.lib"
|
||||
ImportLibrary=""
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
@ -151,12 +151,12 @@
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../3rdparty/lib"
|
||||
ModuleDefinitionFile=""
|
||||
GenerateDebugInformation="true"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
EntryPointSymbol="wWinMainCRTStartup"
|
||||
ImportLibrary="../../bin/$(ConfigurationName)/mC2.lib"
|
||||
ImportLibrary=""
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
Loading…
x
Reference in New Issue
Block a user