X-Git-Url: http://dolda2000.com/gitweb/?p=tpkg.git;a=blobdiff_plain;f=tpkg;h=319d2482b831d51c8ef2a921863dedcc4904e053;hp=aba1fd0b8e4997280e0e15cd743f882bd4c7af06;hb=HEAD;hpb=d414a6a0a1a7006075317b1aa1566ab59ac3ef6e diff --git a/tpkg b/tpkg index aba1fd0..01cf38e 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,13 +255,20 @@ 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(), sb.st_mtime)) + os.utime(tp, ns=(round(time.time() * 1e9), round(sb.st_mtime * 1e9))) def uninstall(pfx, pkg): for fn in pfx.pkgfiles(pkg):