Copy temp database files for sqlite3
This commit is contained in:
@@ -27,7 +27,7 @@ from time import time
|
|||||||
from gi.repository import GdkPixbuf, Gio
|
from gi.repository import GdkPixbuf, Gio
|
||||||
|
|
||||||
|
|
||||||
def get_game(task, current_time, parent_widget, row, importer):
|
def get_game(task, current_time, parent_widget, row):
|
||||||
values = {}
|
values = {}
|
||||||
|
|
||||||
values["game_id"] = f"itch_{row[0]}"
|
values["game_id"] = f"itch_{row[0]}"
|
||||||
@@ -95,7 +95,6 @@ def get_games_async(parent_widget, rows, importer):
|
|||||||
current_time,
|
current_time,
|
||||||
parent_widget,
|
parent_widget,
|
||||||
row,
|
row,
|
||||||
importer,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
@@ -113,10 +112,8 @@ def get_games_async(parent_widget, rows, importer):
|
|||||||
def itch_parser(parent_widget):
|
def itch_parser(parent_widget):
|
||||||
schema = parent_widget.schema
|
schema = parent_widget.schema
|
||||||
|
|
||||||
database_path = (
|
database_path = (Path(schema.get_string("itch-location")) / "db").expanduser()
|
||||||
Path(schema.get_string("itch-location")) / "db" / "butler.db"
|
if not database_path.exists():
|
||||||
).expanduser()
|
|
||||||
if not database_path.is_file():
|
|
||||||
if Path("~/.var/app/io.itch.itch/config/itch/").expanduser().exists():
|
if Path("~/.var/app/io.itch.itch/config/itch/").expanduser().exists():
|
||||||
schema.set_string("itch-location", "~/.var/app/io.itch.itch/config/itch/")
|
schema.set_string("itch-location", "~/.var/app/io.itch.itch/config/itch/")
|
||||||
elif (parent_widget.config_dir / "itch").exists():
|
elif (parent_widget.config_dir / "itch").exists():
|
||||||
@@ -126,16 +123,16 @@ def itch_parser(parent_widget):
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
database_path = (
|
database_path = (Path(schema.get_string("itch-location")) / "db").expanduser()
|
||||||
Path(schema.get_string("itch-location")) / "db" / "butler.db"
|
|
||||||
).expanduser()
|
|
||||||
|
|
||||||
db_cache_dir = parent_widget.cache_dir / "cartridges" / "itch"
|
db_cache_dir = parent_widget.cache_dir / "cartridges" / "itch"
|
||||||
db_cache_dir.mkdir(parents=True, exist_ok=True)
|
db_cache_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# Copy the file because sqlite3 doesn't like databases in /run/user/
|
# Copy the file because sqlite3 doesn't like databases in /run/user/
|
||||||
database_tmp_path = db_cache_dir / "butler.db"
|
database_tmp_path = db_cache_dir / "butler.db"
|
||||||
copyfile(database_path, database_tmp_path)
|
|
||||||
|
for db_file in database_path.glob("butler.db*"):
|
||||||
|
copyfile(db_file, (db_cache_dir / db_file.name))
|
||||||
|
|
||||||
db_request = """
|
db_request = """
|
||||||
SELECT
|
SELECT
|
||||||
@@ -157,6 +154,7 @@ def itch_parser(parent_widget):
|
|||||||
cursor = connection.execute(db_request)
|
cursor = connection.execute(db_request)
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
# No need to unlink temp files as they disappear when the connection is closed
|
||||||
database_tmp_path.unlink(missing_ok=True)
|
database_tmp_path.unlink(missing_ok=True)
|
||||||
|
|
||||||
importer = parent_widget.importer
|
importer = parent_widget.importer
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ def lutris_parser(parent_widget):
|
|||||||
|
|
||||||
schema = parent_widget.schema
|
schema = parent_widget.schema
|
||||||
|
|
||||||
database_path = (Path(schema.get_string("lutris-location")) / "pga.db").expanduser()
|
database_path = (Path(schema.get_string("lutris-location"))).expanduser()
|
||||||
if not database_path.is_file():
|
if not database_path.exists():
|
||||||
if Path("~/.var/app/net.lutris.Lutris/data/lutris/").expanduser().exists():
|
if Path("~/.var/app/net.lutris.Lutris/data/lutris/").expanduser().exists():
|
||||||
schema.set_string(
|
schema.set_string(
|
||||||
"lutris-location", "~/.var/app/net.lutris.Lutris/data/lutris/"
|
"lutris-location", "~/.var/app/net.lutris.Lutris/data/lutris/"
|
||||||
@@ -51,7 +51,7 @@ def lutris_parser(parent_widget):
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
database_path = (Path(schema.get_string("lutris-location")) / "pga.db").expanduser()
|
database_path = (Path(schema.get_string("lutris-location"))).expanduser()
|
||||||
cache_dir = Path(schema.get_string("lutris-cache-location")).expanduser()
|
cache_dir = Path(schema.get_string("lutris-cache-location")).expanduser()
|
||||||
|
|
||||||
db_cache_dir = parent_widget.cache_dir / "cartridges" / "lutris"
|
db_cache_dir = parent_widget.cache_dir / "cartridges" / "lutris"
|
||||||
@@ -59,7 +59,9 @@ def lutris_parser(parent_widget):
|
|||||||
|
|
||||||
# Copy the file because sqlite3 doesn't like databases in /run/user/
|
# Copy the file because sqlite3 doesn't like databases in /run/user/
|
||||||
database_tmp_path = db_cache_dir / "pga.db"
|
database_tmp_path = db_cache_dir / "pga.db"
|
||||||
copyfile(database_path, database_tmp_path)
|
|
||||||
|
for db_file in database_path.glob("pga.db*"):
|
||||||
|
copyfile(db_file, (db_cache_dir / db_file.name))
|
||||||
|
|
||||||
db_request = """
|
db_request = """
|
||||||
SELECT
|
SELECT
|
||||||
@@ -78,6 +80,7 @@ def lutris_parser(parent_widget):
|
|||||||
cursor = connection.execute(db_request)
|
cursor = connection.execute(db_request)
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
# No need to unlink temp files as they disappear when the connection is closed
|
||||||
database_tmp_path.unlink(missing_ok=True)
|
database_tmp_path.unlink(missing_ok=True)
|
||||||
|
|
||||||
if schema.get_boolean("steam"):
|
if schema.get_boolean("steam"):
|
||||||
|
|||||||
Reference in New Issue
Block a user