mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-26 22:56: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:
parent
35be8342e3
commit
18273d470b
13
osc/core.py
13
osc/core.py
@ -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')
|
||||
f.write(meta)
|
||||
f.close()
|
||||
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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user