|
|
@ -7,11 +7,27 @@ import sqlite3 |
|
|
import time |
|
|
import time |
|
|
import time |
|
|
import time |
|
|
|
|
|
|
|
|
def create_temp(): |
|
|
|
|
|
|
|
|
def create_temp_dir(): |
|
|
name= 'fsb{}'.format(hex(time.time_ns())[2:]) |
|
|
name= 'fsb{}'.format(hex(time.time_ns())[2:]) |
|
|
os.mkdir(name) |
|
|
os.mkdir(name) |
|
|
return 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): |
|
|
def lookup(cur,imohash,realhash=None): |
|
|
if realhash is not None: |
|
|
if realhash is not None: |
|
|
cur.execute('SELECT path FROM paths where blake=?',[realhash]) |
|
|
cur.execute('SELECT path FROM paths where blake=?',[realhash]) |
|
|
@ -23,9 +39,11 @@ def lookup(cur,imohash,realhash=None): |
|
|
def restore(database,source,destination): |
|
|
def restore(database,source,destination): |
|
|
con=sqlite3.connect(database) |
|
|
con=sqlite3.connect(database) |
|
|
cur=con.cursor() |
|
|
cur=con.cursor() |
|
|
temp = create_temp() |
|
|
|
|
|
|
|
|
temp = create_hash_lookup(source) |
|
|
hashes = hashify(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) |
|
|
ppath = os.path.join(source,path) |
|
|
qpath=lookup(cur,imohash,realhash) |
|
|
qpath=lookup(cur,imohash,realhash) |
|
|
qpath=os.path.join(temp,qpath) |
|
|
qpath=os.path.join(temp,qpath) |
|
|
|