Browse Source

Fixed bug with temp dir

need to address the same file in different places
restore_refactor
Raphael Roberts 7 years ago
parent
commit
76ec829782
  1. 5
      backup.py
  2. 12
      restore.py

5
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,

12
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()

Loading…
Cancel
Save