1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-27 15:06:15 +01:00

When updating working copies, replace the .osc/_files file in an atomic way,

preventing hosed working copies when the update is interrupted. An empty
.osc/_files file could result, leading to the following sympton upon subsequent
update:

 % osc up
'foobar' is not a valid working copy.
When parsing .osc/_files, the following error was encountered:
no element found: line 1, column 0
This commit is contained in:
Dr. Peter Poeml 2009-06-05 19:42:33 +00:00
parent 35be8342e3
commit 18273d470b

View File

@ -888,9 +888,16 @@ class Package:
It is replaced with the version pulled from upstream.
"""
meta = ''.join(show_files_meta(self.apiurl, self.prjname, self.name, revision=revision))
f = open(os.path.join(self.storedir, '_files'), 'w')
try:
f = open(os.path.join(self.storedir, '_files.new'), 'w')
f.write(meta)
f.close()
os.rename(os.path.join(self.storedir, '_files.new'), os.path.join(self.storedir, '_files'))
except:
raise
finally:
if os.path.exists(os.path.join(self.storedir, '_files.new')):
os.unlink(os.path.join(self.storedir, '_files.new'))
def update_datastructs(self):
"""