mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-04-28 08:44:59 +00:00
Handle a permission error on macOS #158
Although this does not fix the issue, when the error occurs, it will provide more information to users
This commit is contained in:
@@ -5,7 +5,7 @@ import shutil
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
import getpass
|
import getpass
|
||||||
from sys import exit
|
from sys import exit, platform as osname
|
||||||
from Whatsapp_Chat_Exporter.utility import CLEAR_LINE, WhatsAppIdentifier
|
from Whatsapp_Chat_Exporter.utility import CLEAR_LINE, WhatsAppIdentifier
|
||||||
from Whatsapp_Chat_Exporter.bplist import BPListReader
|
from Whatsapp_Chat_Exporter.bplist import BPListReader
|
||||||
try:
|
try:
|
||||||
@@ -46,15 +46,25 @@ class BackupExtractor:
|
|||||||
Returns:
|
Returns:
|
||||||
bool: True if encrypted, False otherwise.
|
bool: True if encrypted, False otherwise.
|
||||||
"""
|
"""
|
||||||
with sqlite3.connect(os.path.join(self.base_dir, "Manifest.db")) as db:
|
try:
|
||||||
c = db.cursor()
|
with sqlite3.connect(os.path.join(self.base_dir, "Manifest.db")) as db:
|
||||||
try:
|
c = db.cursor()
|
||||||
c.execute("SELECT count() FROM Files")
|
try:
|
||||||
c.fetchone() # Execute and fetch to trigger potential errors
|
c.execute("SELECT count() FROM Files")
|
||||||
except (sqlite3.OperationalError, sqlite3.DatabaseError):
|
c.fetchone() # Execute and fetch to trigger potential errors
|
||||||
return True
|
except (sqlite3.OperationalError, sqlite3.DatabaseError):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
except sqlite3.DatabaseError as e:
|
||||||
|
if e == "authorization denied" and osname == "darwin":
|
||||||
|
logger.error(
|
||||||
|
"You don't have permission to access the backup database. Please"
|
||||||
|
"check your permissions or try moving the backup to somewhere else."
|
||||||
|
)
|
||||||
|
exit(8)
|
||||||
else:
|
else:
|
||||||
return False
|
raise e
|
||||||
|
|
||||||
def _extract_encrypted_backup(self):
|
def _extract_encrypted_backup(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user