diff --git a/backup.py b/backup.py index d4ce063..0c3509a 100755 --- a/backup.py +++ b/backup.py @@ -1,11 +1,11 @@ #!/usr/bin/python from imohash.imohash import hashfile as _imohash +import argparse import hashlib -import multiprocessing import os import psutil import sqlite3 -import argparse + # https://stackoverflow.com/a/17782753 def file_hash(path, block_size=4096*8): ''' @@ -40,7 +40,6 @@ def hashify(top): real_hash = None if imohash in imo_hashes: real_hash = file_hash(filepath) - print(file) ret.append( ( filepath, diff --git a/restore.py b/restore.py index 09fae39..b59290e 100755 --- a/restore.py +++ b/restore.py @@ -1,13 +1,14 @@ #!/usr/bin/python from backup import hashify import argparse -import datetime -import time -import shutil import os +import shutil import sqlite3 +import time +import time + def create_temp(): - name= 'fsb{}'.format(datetime.datetime.today()) + name= 'fsb{}'.format(hex(time.time_ns())[2:]) os.mkdir(name) return name def lookup(cur,imohash,realhash=None): @@ -30,7 +31,8 @@ def restore(database,source,destination): parent = os.path.dirname(qpath) if not os.path.exists(parent): os.makedirs(parent) - shutil.move(ppath,qpath) + print(ppath,qpath,sep = '->') + os.rename(ppath,qpath) os.rename(temp,destination) if __name__ == "__main__": parser = argparse.ArgumentParser()