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
|
from pathlib import Path
|
||||||
import pickledb
|
import pickledb
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
PATH = Path("/data/backup/Photos")
|
PATH = Path("/data/backup/Photos")
|
||||||
PAR2_DB = PATH.joinpath(".par2.db")
|
PAR2_DB = PATH.joinpath(".par2.db")
|
||||||
|
@ -23,16 +24,28 @@ extensions = {
|
||||||
".mp4",
|
".mp4",
|
||||||
}
|
}
|
||||||
|
|
||||||
files = list(PATH.rglob("*"))
|
stored_exception = None
|
||||||
|
|
||||||
for file in files:
|
try:
|
||||||
if file.suffix.lower() in extensions:
|
files = list(PATH.rglob("*"))
|
||||||
rel = str(file.relative_to(PATH))
|
|
||||||
if not db.exists(rel):
|
for file in files:
|
||||||
result = subprocess.call(["lib/par2", "create", str(file)])
|
if file.suffix.lower() in extensions:
|
||||||
if result == 0:
|
rel = str(file.relative_to(PATH))
|
||||||
db.set(rel, "done")
|
if not db.exists(rel):
|
||||||
else:
|
result = subprocess.call(["lib/par2", "create", str(file)])
|
||||||
continue
|
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()
|
db.dump()
|
||||||
|
|
||||||
|
print("Done.")
|
||||||
|
|
Loading…
Reference in a new issue