summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2024-07-03 00:54:53 +0200
committercos <cos>2024-07-03 11:31:23 +0200
commit262585c5dfb87170d2c136cf1c15d007e13eba52 (patch)
tree24ac41dc37f95b9cf707136b1ebd7743461be1c5
parenteab48739a66636da46186a47d603f3a9b5bafa0a (diff)
downloadAntennaPodDbFixer-262585c5dfb87170d2c136cf1c15d007e13eba52.zip
Detect missing dbpage extension
While sqlite3 is documented to build with the dbpage extension by default, one can not simply rely on it always being available. Notably debian trixie (3.46.0-1) lacks the extension.
-rwxr-xr-xAntennaPodDbFixer.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/AntennaPodDbFixer.py b/AntennaPodDbFixer.py
index f149a6f..56d77a4 100755
--- a/AntennaPodDbFixer.py
+++ b/AntennaPodDbFixer.py
@@ -10,6 +10,17 @@ if len(sys.argv) > 1:
else:
inputPath = input("Enter file path to your corrupted AntennaPod database: ")
+DBPAGE_SYM = "ENABLE_DBPAGE_VTAB"
+dbpage_ext = subprocess.run([
+ "sh", "-c", "strings $( which sqlite3 ) | grep " + DBPAGE_SYM],
+ capture_output=True,
+ text=True
+ ).stdout.strip()
+if dbpage_ext != DBPAGE_SYM:
+ print("Could not detect sqlite3 dbpage extension. Aborting.", file=sys.stderr)
+ print("https://sqlite.org/dbpage.html (required by .recover)", file=sys.stderr)
+ exit(1)
+
corruptedVersion = subprocess.run(["sqlite3", inputPath, "PRAGMA user_version;"], capture_output=True, text=True).stdout.strip()
if corruptedVersion == "0":
print("Error: File not found, not a database, or too corrupted for this script.")