minor bug fix

This commit is contained in:
2021-09-06 21:40:13 +08:00
parent 8c65d63900
commit 829b2f9bc2
4 changed files with 13 additions and 5 deletions

View File

@@ -47,6 +47,8 @@ class BackupTask(Thread):
from game_backuper.leveldb import have_leveldb
if not have_leveldb:
raise ValueError('Leveldb is not supported.')
if not exists(f.full_path):
continue
from game_backuper.leveldb import (
list_leveldb_entries,
leveldb_stats,

View File

@@ -52,6 +52,8 @@ class Db:
self.__write_version()
if 'files' not in self._exist_table:
self.db.execute(FILES_TABLE)
if 'filetype' not in self._exist_table:
self.db.execute(FILETYPE_TABLE)
self.db.commit()
def __init__(self, loc: str):

View File

@@ -1,16 +1,16 @@
try:
from plyvel import DB
have_leveldb = True
from typing import List
from hashlib import sha512
from base64 import b85encode
from collections import namedtuple
from sqlite3 import connect
except ImportError:
have_leveldb = False
if have_leveldb:
from typing import List
from hashlib import sha512
from base64 import b85encode
from collections import namedtuple
from sqlite3 import connect
LeveldbStats = namedtuple('LeveldbStats', ['hash', 'size'])
MAP_TABLE = '''CREATE TABLE map (
key TEXT,

View File

@@ -2,6 +2,8 @@ from game_backuper.config import Config
from game_backuper.cml import Opts
from game_backuper.db import Db
from game_backuper.backuper import Backuper
from os import makedirs
from os.path import exists
def main(cm=None):
@@ -10,6 +12,8 @@ def main(cm=None):
cm = sys.argv[1:]
cml = Opts(cm)
cfg = Config(cml.config_file)
if not exists(cfg.dest):
makedirs(cfg.dest)
db = Db(cfg.dest)
bk = Backuper(db, cfg, cml)
return bk.run()