/[packages]/cauldron/xbmc/current/SOURCES/0001-hack-workaround-for-old-incompatible-PVR-addon-datab.patch
ViewVC logotype

Contents of /cauldron/xbmc/current/SOURCES/0001-hack-workaround-for-old-incompatible-PVR-addon-datab.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 389214 - (show annotations) (download)
Thu Jan 17 21:30:27 2013 UTC (11 years, 3 months ago) by pterjan
File size: 3226 byte(s)
oops
1 From fb42d248dd697cc063f3565df749e80aeae3ff38 Mon Sep 17 00:00:00 2001
2 From: Anssi Hannula <anssi@xbmc.org>
3 Date: Sat, 17 Mar 2012 03:35:38 +0200
4 Subject: [PATCH] hack: workaround for old incompatible PVR addon databases
5
6 This needs to be cleaned up for inclusion to upstream XBMC git.
7 Specifically, it needs to be more generic (i.e. not limited to the PVR
8 incompatibility nor to the addon db and possibly limited to upgrades
9 only (no drop()ing) or alternatively some backup should be made of the
10 old db.
11
12 Bugfixes to sqlitedataset.cpp should be separated and drop() needs to
13 be called in generic UpdateVersion() on failure to prevent continuing
14 failure.
15 diff -Nurpa -x '*~' -x '*.orig' -x '*.rej' -x '*.swp' xbmc-Frodo_rc3/xbmc/addons/AddonDatabase.cpp xbmc-Frodo_rc3/xbmc/addons/AddonDatabase.cpp
16 --- xbmc-Frodo_rc3/xbmc/addons/AddonDatabase.cpp 2013-01-03 05:29:19.000000000 +0200
17 +++ xbmc-Frodo_rc3/xbmc/addons/AddonDatabase.cpp 2013-01-09 15:08:57.509707610 +0200
18 @@ -40,7 +40,24 @@ CAddonDatabase::~CAddonDatabase()
19
20 bool CAddonDatabase::Open()
21 {
22 - return CDatabase::Open();
23 + bool ok = CDatabase::Open();
24 + if (ok)
25 + {
26 + try
27 + {
28 + // perform a validation to see if this db was broken during an upgrade from
29 + // an old PVR addon database
30 + m_pDS->exec("select addon,version,optional from dependencies limit 1");
31 + }
32 + catch (...)
33 + {
34 + // broken db, drop and recreate - hack
35 + try { m_pDB->drop(); } catch(...) { }
36 + Close();
37 + ok = CDatabase::Open();
38 + }
39 + }
40 + return ok;
41 }
42
43 bool CAddonDatabase::CreateTables()
44 @@ -101,6 +118,7 @@ bool CAddonDatabase::CreateTables()
45
46 bool CAddonDatabase::UpdateOldVersion(int version)
47 {
48 + try {
49 if (version < 13)
50 {
51 m_pDS->exec("CREATE TABLE dependencies (id integer, addon text, version text, optional boolean)\n");
52 @@ -115,6 +133,16 @@ bool CAddonDatabase::UpdateOldVersion(in
53 m_pDS->exec("CREATE TABLE blacklist (id integer primary key, addonID text, version text)\n");
54 m_pDS->exec("CREATE UNIQUE INDEX idxBlack ON blacklist(addonID)");
55 }
56 + }
57 + catch (...)
58 + {
59 + CLog::Log(LOGERROR, "Error attempting to upgrade an old addon database!");
60 + RollbackTransaction();
61 + // hack - drop db or the unupgraded db will be left around and next upgrade will
62 + // fail as well:
63 + try { m_pDB->drop(); } catch (...) { }
64 + return false;
65 + }
66 return true;
67 }
68
69 diff -Nurpa -x '*~' -x '*.orig' -x '*.rej' -x '*.swp' xbmc-Frodo_rc3/xbmc/dbwrappers/sqlitedataset.cpp xbmc-Frodo_rc3/xbmc/dbwrappers/sqlitedataset.cpp
70 --- xbmc-Frodo_rc3/xbmc/dbwrappers/sqlitedataset.cpp 2013-01-03 05:29:19.000000000 +0200
71 +++ xbmc-Frodo_rc3/xbmc/dbwrappers/sqlitedataset.cpp 2013-01-09 15:05:41.851381387 +0200
72 @@ -317,7 +317,10 @@ int SqliteDatabase::copy(const char *bac
73 int SqliteDatabase::drop() {
74 if (active == false) throw DbErrors("Can't drop database: no active connection...");
75 disconnect();
76 - if (!unlink(db.c_str())) {
77 + CStdString db_fullpath;
78 + URIUtils::AddFileToFolder(host, db, db_fullpath);
79 +
80 + if (unlink(db_fullpath.c_str())) {
81 throw DbErrors("Can't drop database: can't unlink the file %s,\nError: %s",db.c_str(),strerror(errno));
82 }
83 return DB_COMMAND_OK;

  ViewVC Help
Powered by ViewVC 1.1.30