Add support for cloud placeholder on Windows (Such as OneDrive)

This commit is contained in:
2022-01-16 17:54:49 +08:00
parent d8f58df3e2
commit 84f2cb1fea
7 changed files with 67 additions and 10 deletions

View File

@@ -2,7 +2,7 @@ from sqlite3 import connect
from os.path import join
from typing import List, Union
from threading import Lock
from game_backuper.file import File
from game_backuper.file import File, hydrate_file_if_needed
from game_backuper.filetype import FileType
@@ -56,11 +56,13 @@ class Db:
self.db.execute(FILETYPE_TABLE)
self.db.commit()
def __init__(self, loc: str):
def __init__(self, loc: str, optimize_db: bool = False):
fn = join(loc, "data.db")
hydrate_file_if_needed(fn)
self.db = connect(fn, check_same_thread=False)
self.db.execute('VACUUM;')
self.db.commit()
if optimize_db:
self.db.execute('VACUUM;')
self.db.commit()
ok = self.__check_database()
if not ok:
self.__create_table()