Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
cosmetics: align code
  • Loading branch information
Jonathan Marshall committed Jul 8, 2012
1 parent 6107ee4 commit 51bc645
Show file tree
Hide file tree
Showing 4 changed files with 561 additions and 561 deletions.
124 changes: 62 additions & 62 deletions xbmc/TextureDatabase.cpp
Expand Up @@ -74,70 +74,70 @@ bool CTextureDatabase::CreateTables()

bool CTextureDatabase::UpdateOldVersion(int version)
{
if (version < 7)
{ // update all old thumb://foo urls to image://foo?size=thumb
m_pDS->query("select id,texture from path where texture like 'thumb://%'");
while (!m_pDS->eof())
{
unsigned int id = m_pDS->fv(0).get_asInt();
CURL url(m_pDS->fv(1).get_asString());
m_pDS2->exec(PrepareSQL("update path set texture='image://%s?size=thumb' where id=%u", url.GetHostName().c_str(), id));
m_pDS->next();
}
m_pDS->query("select id, url from texture where url like 'thumb://%'");
while (!m_pDS->eof())
{
unsigned int id = m_pDS->fv(0).get_asInt();
CURL url(m_pDS->fv(1).get_asString());
m_pDS2->exec(PrepareSQL("update texture set url='image://%s?size=thumb', urlhash=0 where id=%u", url.GetHostName().c_str(), id));
m_pDS->next();
}
m_pDS->close();
}
if (version < 8)
{ // get rid of old cached thumbs as they were previously set to the cached thumb name instead of the source thumb
m_pDS->exec("delete from path");
}
if (version < 9)
{ // get rid of the old path table and add the type column
m_pDS->dropIndex("path", "idxPath");
m_pDS->exec("DROP TABLE path");
m_pDS->exec("CREATE TABLE path (id integer primary key, urlhash integer, url text, type text, texture text)\n");
m_pDS->exec("CREATE INDEX idxPath ON path(urlhash, type)");
}
if (version < 10)
{ // get rid of urlhash in both tables...
m_pDS->dropIndex("path", "idxPath");
m_pDS->exec("DROP TABLE path");
m_pDS->exec("CREATE TABLE path (id integer primary key, url text, type text, texture text)\n");
m_pDS->exec("CREATE INDEX idxPath ON path(url, type)");

m_pDS->dropIndex("texture", "idxTexture");
m_pDS->exec("CREATE TEMPORARY TABLE texture_backup(id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck)");
m_pDS->exec("INSERT INTO texture_backup SELECT id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck FROM texture");
m_pDS->exec("DROP TABLE texture");
m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, usecount integer, lastusetime text, imagehash text, lasthashcheck text)");
m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
m_pDS->exec("INSERT INTO texture SELECT * FROM texture_backup");
m_pDS->exec("DROP TABLE texture_backup");
}
if (version < 11)
{ // get rid of cached URLs that don't have the correct extension
m_pDS->exec("DELETE FROM texture WHERE SUBSTR(cachedUrl,-4,4) NOT IN ('.jpg', '.png')");
}
if (version < 12)
{ // create new sizes table and move usecount info to it.
m_pDS->exec("DROP TABLE texture");
m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, imagehash text, lasthashcheck text)");
m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
m_pDS->exec("CREATE TABLE sizes (idtexture integer, size integer, width integer, height integer, usecount integer, lastusetime text)");
m_pDS->exec("CREATE INDEX idxSize ON sizes(idtexture, size)");
m_pDS->exec("CREATE TRIGGER textureDelete AFTER delete ON texture FOR EACH ROW BEGIN delete from sizes where sizes.idtexture=old.id; END");
if (version < 7)
{ // update all old thumb://foo urls to image://foo?size=thumb
m_pDS->query("select id,texture from path where texture like 'thumb://%'");
while (!m_pDS->eof())
{
unsigned int id = m_pDS->fv(0).get_asInt();
CURL url(m_pDS->fv(1).get_asString());
m_pDS2->exec(PrepareSQL("update path set texture='image://%s?size=thumb' where id=%u", url.GetHostName().c_str(), id));
m_pDS->next();
}
if (version < 13)
{ // index for updateusecount
m_pDS->exec("CREATE INDEX idxSize2 ON sizes(idtexture, width, height)");
m_pDS->query("select id, url from texture where url like 'thumb://%'");
while (!m_pDS->eof())
{
unsigned int id = m_pDS->fv(0).get_asInt();
CURL url(m_pDS->fv(1).get_asString());
m_pDS2->exec(PrepareSQL("update texture set url='image://%s?size=thumb', urlhash=0 where id=%u", url.GetHostName().c_str(), id));
m_pDS->next();
}
m_pDS->close();
}
if (version < 8)
{ // get rid of old cached thumbs as they were previously set to the cached thumb name instead of the source thumb
m_pDS->exec("delete from path");
}
if (version < 9)
{ // get rid of the old path table and add the type column
m_pDS->dropIndex("path", "idxPath");
m_pDS->exec("DROP TABLE path");
m_pDS->exec("CREATE TABLE path (id integer primary key, urlhash integer, url text, type text, texture text)\n");
m_pDS->exec("CREATE INDEX idxPath ON path(urlhash, type)");
}
if (version < 10)
{ // get rid of urlhash in both tables...
m_pDS->dropIndex("path", "idxPath");
m_pDS->exec("DROP TABLE path");
m_pDS->exec("CREATE TABLE path (id integer primary key, url text, type text, texture text)\n");
m_pDS->exec("CREATE INDEX idxPath ON path(url, type)");

m_pDS->dropIndex("texture", "idxTexture");
m_pDS->exec("CREATE TEMPORARY TABLE texture_backup(id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck)");
m_pDS->exec("INSERT INTO texture_backup SELECT id,url,cachedurl,usecount,lastusetime,imagehash,lasthashcheck FROM texture");
m_pDS->exec("DROP TABLE texture");
m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, usecount integer, lastusetime text, imagehash text, lasthashcheck text)");
m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
m_pDS->exec("INSERT INTO texture SELECT * FROM texture_backup");
m_pDS->exec("DROP TABLE texture_backup");
}
if (version < 11)
{ // get rid of cached URLs that don't have the correct extension
m_pDS->exec("DELETE FROM texture WHERE SUBSTR(cachedUrl,-4,4) NOT IN ('.jpg', '.png')");
}
if (version < 12)
{ // create new sizes table and move usecount info to it.
m_pDS->exec("DROP TABLE texture");
m_pDS->exec("CREATE TABLE texture (id integer primary key, url text, cachedurl text, imagehash text, lasthashcheck text)");
m_pDS->exec("CREATE INDEX idxTexture ON texture(url)");
m_pDS->exec("CREATE TABLE sizes (idtexture integer, size integer, width integer, height integer, usecount integer, lastusetime text)");
m_pDS->exec("CREATE INDEX idxSize ON sizes(idtexture, size)");
m_pDS->exec("CREATE TRIGGER textureDelete AFTER delete ON texture FOR EACH ROW BEGIN delete from sizes where sizes.idtexture=old.id; END");
}
if (version < 13)
{ // index for updateusecount
m_pDS->exec("CREATE INDEX idxSize2 ON sizes(idtexture, width, height)");
}
return true;
}

Expand Down
28 changes: 14 additions & 14 deletions xbmc/addons/AddonDatabase.cpp
Expand Up @@ -101,20 +101,20 @@ bool CAddonDatabase::CreateTables()

bool CAddonDatabase::UpdateOldVersion(int version)
{
if (version < 13)
{
m_pDS->exec("CREATE TABLE dependencies (id integer, addon text, version text, optional boolean)\n");
m_pDS->exec("CREATE INDEX idxDependencies ON dependencies(id)");
}
if (version < 14)
{
m_pDS->exec("ALTER TABLE addon add minversion text");
}
if (version < 15)
{
m_pDS->exec("CREATE TABLE blacklist (id integer primary key, addonID text, version text)\n");
m_pDS->exec("CREATE UNIQUE INDEX idxBlack ON blacklist(addonID)");
}
if (version < 13)
{
m_pDS->exec("CREATE TABLE dependencies (id integer, addon text, version text, optional boolean)\n");
m_pDS->exec("CREATE INDEX idxDependencies ON dependencies(id)");
}
if (version < 14)
{
m_pDS->exec("ALTER TABLE addon add minversion text");
}
if (version < 15)
{
m_pDS->exec("CREATE TABLE blacklist (id integer primary key, addonID text, version text)\n");
m_pDS->exec("CREATE UNIQUE INDEX idxBlack ON blacklist(addonID)");
}
return true;
}

Expand Down

0 comments on commit 51bc645

Please sign in to comment.