|
|
@ -11,14 +11,15 @@ def create_temp(): |
|
|
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 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]) |
|
|
else: |
|
|
else: |
|
|
cur.execute('SELECT path FROM paths where imohash=?',[imohash]) |
|
|
cur.execute('SELECT path FROM paths where imohash=?',[imohash]) |
|
|
res = cur.fetchone() |
|
|
|
|
|
if len(res) == 1: |
|
|
|
|
|
return res[0] |
|
|
|
|
|
|
|
|
res = cur.fetchall() |
|
|
|
|
|
return res |
|
|
|
|
|
|
|
|
def restore(database,source,destination): |
|
|
def restore(database,source,destination): |
|
|
con=sqlite3.connect(database) |
|
|
con=sqlite3.connect(database) |
|
|
cur=con.cursor() |
|
|
cur=con.cursor() |
|
|
@ -34,6 +35,7 @@ def restore(database,source,destination): |
|
|
print(ppath,qpath,sep = '->') |
|
|
print(ppath,qpath,sep = '->') |
|
|
os.rename(ppath,qpath) |
|
|
os.rename(ppath,qpath) |
|
|
os.rename(temp,destination) |
|
|
os.rename(temp,destination) |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
if __name__ == "__main__": |
|
|
parser = argparse.ArgumentParser() |
|
|
parser = argparse.ArgumentParser() |
|
|
parser.add_argument('database') |
|
|
parser.add_argument('database') |
|
|
|