def __iter__(self):
def scan(lp, fp):
- dpre = "" if (lp is "") else lp + "/"
+ dpre = "" if (lp == "") else lp + "/"
for dent in os.scandir(fp):
dpath = dpre + dent.name
if dent.is_dir():
os.makedirs(tpdir)
tmpp = tp + ".tpkg-new"
sb = fl.stat()
- with open(tmpp, "wb") as ofp:
- os.fchmod(ofp.fileno(), sb.st_mode & 0o7777)
- with fl.open() as ifp:
- dig = copy(ofp, ifp)
- pfx.regfile(fl.path, pkgname, dig)
+ try:
+ with open(tmpp, "wb") as ofp:
+ os.fchmod(ofp.fileno(), sb.st_mode & 0o7777)
+ with fl.open() as ifp:
+ dig = copy(ofp, ifp)
+ pfx.regfile(fl.path, pkgname, dig)
+ except:
+ try:
+ os.unlink(tmpp)
+ except FileNotFoundError:
+ pass
+ raise
os.rename(tmpp, tp)
- os.utime(tp, ns=(time.time() * 1e9, sb.st_mtime * 1e9))
+ os.utime(tp, ns=(round(time.time() * 1e9), round(sb.st_mtime * 1e9)))
def uninstall(pfx, pkg):
for fn in pfx.pkgfiles(pkg):