diff --git a/backup.py b/backup.py index e54d6f4..f5b0d51 100755 --- a/backup.py +++ b/backup.py @@ -39,7 +39,6 @@ def hashify(top): imohash = _imohash(filepath) real_hash = None if imohash in imo_hashes: - print(filepath) real_hash = file_hash(filepath) else: imo_hashes.add(imohash) diff --git a/restore.py b/restore.py index e13c094..505fbe8 100755 --- a/restore.py +++ b/restore.py @@ -7,11 +7,27 @@ import sqlite3 import time import time -def create_temp(): +def create_temp_dir(): name= 'fsb{}'.format(hex(time.time_ns())[2:]) os.mkdir(name) return name +def copy_file_temp(path): + name= 'fsb{}'.format(hex(time.time_ns())[2:]) + os.copy(path,name) + return name + +def super_rename(src,dst): + parent = + if not o + +def create_hash_lookup(top): + hashes = hasifiy(top) + ret = {} + for _hash in hashes: + path,*two_hashes = _hash + ret.setdefault(two_hashes,[]).append(path) + return ret def lookup(cur,imohash,realhash=None): if realhash is not None: cur.execute('SELECT path FROM paths where blake=?',[realhash]) @@ -23,9 +39,11 @@ def lookup(cur,imohash,realhash=None): def restore(database,source,destination): con=sqlite3.connect(database) cur=con.cursor() - temp = create_temp() + temp = create_hash_lookup(source) hashes = hashify(source) - for path,imohash,realhash in hashes: + for _hashes,paths in hashes.items(): + search_results = lookup(cur,*_hashes) + ppath = os.path.join(source,path) qpath=lookup(cur,imohash,realhash) qpath=os.path.join(temp,qpath)