mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- update: always use 'rev' query parameter when fetching files
This commit is contained in:
parent
e91475508e
commit
58ca66a417
19
osc/core.py
19
osc/core.py
@ -1446,10 +1446,11 @@ rev: %s
|
|||||||
upstream_rev = show_upstream_rev(self.apiurl, self.prjname, self.name, meta=self.meta)
|
upstream_rev = show_upstream_rev(self.apiurl, self.prjname, self.name, meta=self.meta)
|
||||||
return upstream_rev
|
return upstream_rev
|
||||||
|
|
||||||
def __get_files(self, filesmeta):
|
def __get_files(self, fmeta_root):
|
||||||
f = []
|
f = []
|
||||||
fmeta = ET.fromstring(filesmeta)
|
if fmeta_root.get('rev') is None:
|
||||||
for i in fmeta.findall('entry'):
|
raise oscerr.APIError('missing rev attribute in _files:\n%s' % ''.join(ET.tostring(fmeta_root)))
|
||||||
|
for i in fmeta_root.findall('entry'):
|
||||||
skipped = i.get('skipped') is not None
|
skipped = i.get('skipped') is not None
|
||||||
f.append(File(i.get('name'), i.get('md5'),
|
f.append(File(i.get('name'), i.get('md5'),
|
||||||
int(i.get('size')), int(i.get('mtime')), skipped))
|
int(i.get('size')), int(i.get('mtime')), skipped))
|
||||||
@ -1485,8 +1486,7 @@ rev: %s
|
|||||||
if os.path.isfile(os.path.join(self.storedir, '_in_update', '_files')):
|
if os.path.isfile(os.path.join(self.storedir, '_in_update', '_files')):
|
||||||
print 'resuming broken update...'
|
print 'resuming broken update...'
|
||||||
root = ET.parse(os.path.join(self.storedir, '_in_update', '_files')).getroot()
|
root = ET.parse(os.path.join(self.storedir, '_in_update', '_files')).getroot()
|
||||||
fm = ET.tostring(root)
|
rfiles = self.__get_files(root)
|
||||||
rfiles = self.__get_files(fm)
|
|
||||||
kept, added, deleted = self.__get_rev_changes(rfiles)
|
kept, added, deleted = self.__get_rev_changes(rfiles)
|
||||||
# check if we aborted in the middle of a file update
|
# check if we aborted in the middle of a file update
|
||||||
broken_file = os.listdir(os.path.join(self.storedir, '_in_update'))
|
broken_file = os.listdir(os.path.join(self.storedir, '_in_update'))
|
||||||
@ -1532,20 +1532,21 @@ rev: %s
|
|||||||
# this can't happen
|
# this can't happen
|
||||||
elif f in deleted:
|
elif f in deleted:
|
||||||
deleted.remove(f)
|
deleted.remove(f)
|
||||||
self.__update(kept, added, deleted, fm, root.get('rev'), service_files)
|
self.__update(kept, added, deleted, ET.tostring(root), root.get('rev'), service_files)
|
||||||
os.unlink(os.path.join(self.storedir, '_in_update', '_files'))
|
os.unlink(os.path.join(self.storedir, '_in_update', '_files'))
|
||||||
os.rmdir(os.path.join(self.storedir, '_in_update'))
|
os.rmdir(os.path.join(self.storedir, '_in_update'))
|
||||||
# ok everything is ok (hopefully)...
|
# ok everything is ok (hopefully)...
|
||||||
fm = show_files_meta(self.apiurl, self.prjname, self.name, revision=rev, limit_size=limit_size)
|
fm = show_files_meta(self.apiurl, self.prjname, self.name, revision=rev, limit_size=limit_size)
|
||||||
rfiles = self.__get_files(fm)
|
root = ET.fromstring(fm)
|
||||||
|
rfiles = self.__get_files(root)
|
||||||
store_write_string(self.absdir, '_files', fm, subdir='_in_update')
|
store_write_string(self.absdir, '_files', fm, subdir='_in_update')
|
||||||
kept, added, deleted = self.__get_rev_changes(rfiles)
|
kept, added, deleted = self.__get_rev_changes(rfiles)
|
||||||
self.__update(kept, added, deleted, fm, rev, service_files)
|
self.__update(kept, added, deleted, fm, root.get('rev'), service_files)
|
||||||
os.unlink(os.path.join(self.storedir, '_in_update', '_files'))
|
os.unlink(os.path.join(self.storedir, '_in_update', '_files'))
|
||||||
if os.path.isdir(os.path.join(self.storedir, '_in_update')):
|
if os.path.isdir(os.path.join(self.storedir, '_in_update')):
|
||||||
os.rmdir(os.path.join(self.storedir, '_in_update'))
|
os.rmdir(os.path.join(self.storedir, '_in_update'))
|
||||||
|
|
||||||
def __update(self, kept, added, deleted, fm, rev = None, service_files = False):
|
def __update(self, kept, added, deleted, fm, rev, service_files = False):
|
||||||
pathn = getTransActPath(self.dir)
|
pathn = getTransActPath(self.dir)
|
||||||
# check for conflicts with existing files
|
# check for conflicts with existing files
|
||||||
for f in added:
|
for f in added:
|
||||||
|
@ -189,7 +189,7 @@ class TestUpdate(unittest.TestCase):
|
|||||||
self.__check_digests('testUpdateLocalDeletions_files')
|
self.__check_digests('testUpdateLocalDeletions_files')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/restore?rev=latest', file='testUpdateRestore_files')
|
@GET('http://localhost/source/osctest/restore?rev=latest', file='testUpdateRestore_files')
|
||||||
@GET('http://localhost/source/osctest/restore/foo', file='testUpdateRestore_foo')
|
@GET('http://localhost/source/osctest/restore/foo?rev=1', file='testUpdateRestore_foo')
|
||||||
@GET('http://localhost/source/osctest/restore/_meta', file='meta.xml')
|
@GET('http://localhost/source/osctest/restore/_meta', file='meta.xml')
|
||||||
def testUpdateRestore(self):
|
def testUpdateRestore(self):
|
||||||
"""local file 'foo' was deleted with a non osc command and will be restored"""
|
"""local file 'foo' was deleted with a non osc command and will be restored"""
|
||||||
@ -217,7 +217,7 @@ class TestUpdate(unittest.TestCase):
|
|||||||
self.__check_digests('testUpdateLimitSizeNoChange_files', 'bigfile')
|
self.__check_digests('testUpdateLimitSizeNoChange_files', 'bigfile')
|
||||||
|
|
||||||
@GET('http://localhost/source/osctest/limitsize?rev=latest', file='testUpdateLimitSizeAddDelete_filesremote')
|
@GET('http://localhost/source/osctest/limitsize?rev=latest', file='testUpdateLimitSizeAddDelete_filesremote')
|
||||||
@GET('http://localhost/source/osctest/limitsize/exists', file='testUpdateLimitSizeAddDelete_exists')
|
@GET('http://localhost/source/osctest/limitsize/exists?rev=2', file='testUpdateLimitSizeAddDelete_exists')
|
||||||
@GET('http://localhost/source/osctest/limitsize/_meta', file='meta.xml')
|
@GET('http://localhost/source/osctest/limitsize/_meta', file='meta.xml')
|
||||||
def testUpdateLimitSizeAddDelete(self):
|
def testUpdateLimitSizeAddDelete(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user