X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=tpkg;h=a9b30246c7e12294242882b7775cb9d998910c0a;hb=56c4259105cbc928e1c66afaffddabceda2b2e2c;hp=95623f0dd2603e387927825467ce776287ab605c;hpb=ffedc67b9b9380a8702c58a3270b8a568d18c266;p=tpkg.git diff --git a/tpkg b/tpkg index 95623f0..a9b3024 100755 --- a/tpkg +++ b/tpkg @@ -217,7 +217,7 @@ class vfspkg(object): 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(): @@ -255,11 +255,18 @@ def install(pfx, pkg, pkgname): 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))