[entropy.spm] PortagePlugin.xpak: properly use open() in ab+ mode

This commit is contained in:
Fabio Erculiani
2011-09-07 08:34:38 +02:00
parent 22ab952aa1
commit 6c11081a21

View File

@@ -280,15 +280,13 @@ class tbz2:
self.cleanup(datadir)
def recompose_mem(self, xpdata):
self.scan() # Don't care about condition... We'll rewrite the data anyway.
myfile = open(self.file, "ab+")
if not myfile:
raise IOError("file not found")
myfile.seek(-self.xpaksize, os.SEEK_END) # 0,2 or -0,2 just mean EOF.
myfile.truncate()
myfile.write(xpdata+encodeint(len(xpdata))+STOP)
myfile.flush()
myfile.close()
self.scan()
with open(self.file, "ab+") as myfile:
myfile.seek(-self.xpaksize, os.SEEK_END)
myfile.truncate()
myfile.write(xpdata+encodeint(len(xpdata))+STOP)
myfile.flush()
myfile.close()
return 1
def cleanup(self, datadir):