cleanup commit
This commit is contained in:
parent
954375377b
commit
9860ce32ac
1 changed files with 23 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
from pathlib import Path
|
||||
import pickledb
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
PATH = Path("/data/backup/Photos")
|
||||
PAR2_DB = PATH.joinpath(".par2.db")
|
||||
|
@ -23,16 +24,28 @@ extensions = {
|
|||
".mp4",
|
||||
}
|
||||
|
||||
files = list(PATH.rglob("*"))
|
||||
stored_exception = None
|
||||
|
||||
for file in files:
|
||||
if file.suffix.lower() in extensions:
|
||||
rel = str(file.relative_to(PATH))
|
||||
if not db.exists(rel):
|
||||
result = subprocess.call(["lib/par2", "create", str(file)])
|
||||
if result == 0:
|
||||
db.set(rel, "done")
|
||||
else:
|
||||
continue
|
||||
try:
|
||||
files = list(PATH.rglob("*"))
|
||||
|
||||
for file in files:
|
||||
if file.suffix.lower() in extensions:
|
||||
rel = str(file.relative_to(PATH))
|
||||
if not db.exists(rel):
|
||||
result = subprocess.call(["lib/par2", "create", str(file)])
|
||||
if result == 0:
|
||||
db.set(rel, "done")
|
||||
else:
|
||||
continue
|
||||
if stored_exception:
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
stored_exception = sys.exc_info()
|
||||
print("Rescued!")
|
||||
|
||||
print("Saving DB...")
|
||||
|
||||
db.dump()
|
||||
|
||||
print("Done.")
|
||||
|
|
Loading…
Reference in a new issue