Dolda2000 GitWeb
/
tpkg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ffedc67
)
Ensure tpkg-new files are removed on errors.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 13 Jan 2019 01:56:44 +0000
(
02:56
+0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 13 Jan 2019 01:56:44 +0000
(
02:56
+0100)
tpkg
patch
|
blob
|
blame
|
history
diff --git
a/tpkg
b/tpkg
index
95623f0
..
34c8ff3
100755
(executable)
--- a/
tpkg
+++ b/
tpkg
@@
-255,11
+255,18
@@
def install(pfx, pkg, pkgname):
os.makedirs(tpdir)
tmpp = tp + ".tpkg-new"
sb = fl.stat()
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.rename(tmpp, tp)
os.utime(tp, ns=(time.time() * 1e9, sb.st_mtime * 1e9))