- 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