summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/persist_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/persist_data.py')
-rw-r--r--bitbake/lib/bb/persist_data.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py
index 49c9a0d510..bcca791edf 100644
--- a/bitbake/lib/bb/persist_data.py
+++ b/bitbake/lib/bb/persist_data.py
@@ -63,7 +63,7 @@ class SQLTable(collections.abc.MutableMapping):
"""
Decorator that starts a database transaction and creates a database
cursor for performing queries. If no exception is thrown, the
- database results are commited. If an exception occurs, the database
+ database results are committed. If an exception occurs, the database
is rolled back. In all cases, the cursor is closed after the
function ends.
@@ -208,7 +208,7 @@ class SQLTable(collections.abc.MutableMapping):
def __lt__(self, other):
if not isinstance(other, Mapping):
- raise NotImplemented
+ raise NotImplementedError()
return len(self) < len(other)
@@ -249,4 +249,23 @@ def persist(domain, d):
bb.utils.mkdirhier(cachedir)
cachefile = os.path.join(cachedir, "bb_persist_data.sqlite3")
- return SQLTable(cachefile, domain)
+
+ try:
+ return SQLTable(cachefile, domain)
+ except sqlite3.OperationalError:
+ # Sqlite fails to open database when its path is too long.
+ # After testing, 504 is the biggest path length that can be opened by
+ # sqlite.
+ # Note: This code is called before sanity.bbclass and its path length
+ # check
+ max_len = 504
+ if len(cachefile) > max_len:
+ logger.critical("The path of the cache file is too long "
+ "({0} chars > {1}) to be opened by sqlite! "
+ "Your cache file is \"{2}\"".format(
+ len(cachefile),
+ max_len,
+ cachefile))
+ sys.exit(1)
+ else:
+ raise