🐛 Ported sqlite fix from main

This commit is contained in:
GeoffreyCoulaud
2023-06-13 10:32:07 +02:00
parent dbb96a166b
commit 6dd8e3965f
3 changed files with 32 additions and 6 deletions

17
src/utils/sqlite.py Normal file
View File

@@ -0,0 +1,17 @@
from glob import escape
from pathlib import Path
from shutil import copyfile
from gi.repository import GLib
def copy_db(original_path: Path) -> Path:
"""
Copy a sqlite database to a cache dir and return its new path.
The caller in in charge of deleting the returned path's parent dir.
"""
tmp = Path(GLib.Dir.make_tmp())
for file in original_path.parent.glob(f"{escape(original_path.name)}*"):
copy = tmp / file.name
copyfile(str(file), str(copy))
return tmp / original_path.name