mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-05 19:00:56 +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.
|
It is replaced with the version pulled from upstream.
|
||||||
"""
|
"""
|
||||||
meta = ''.join(show_files_meta(self.apiurl, self.prjname, self.name, revision=revision))
|
meta = ''.join(show_files_meta(self.apiurl, self.prjname, self.name, revision=revision))
|
||||||
f = open(os.path.join(self.storedir, '_files'), 'w')
|
try:
|
||||||
f.write(meta)
|
f = open(os.path.join(self.storedir, '_files.new'), 'w')
|
||||||
f.close()
|
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):
|
def update_datastructs(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user