1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-11 07:06:16 +01:00

Merge branch 'fix_osc_lock' of https://github.com/lethliel/osc

The "input" parameter of the metafile's __init__ method can be a bytes
now. (Also, fixes one bug + introduces a new one (old code could break
on an empty bytes b'' and the new code could break on an empty list
(however, the current osc code shouldn't pass such arguments)).)
This commit is contained in:
Marcus Huewe 2019-06-12 11:16:44 +02:00
commit 6362887977

View File

@ -3660,12 +3660,19 @@ class metafile:
self.url = url
self.change_is_required = change_is_required
(fd, self.filename) = tempfile.mkstemp(prefix = 'osc_metafile.', suffix = file_ext)
if not input or isinstance(input[0], str) or isinstance(input, str):
f = os.fdopen(fd, 'w')
f.write(''.join(input))
open_mode = 'w'
input_as_str = None
if not isinstance(input, list):
input = [input]
if isinstance(input[0], str):
input_as_str = ''.join(input)
else:
f = os.fdopen(fd, 'wb')
f.write(b''.join(input))
open_mode = 'wb'
input_as_str = b''.join(input)
f = os.fdopen(fd, open_mode)
f.write(input_as_str)
f.close()
self.hash_orig = dgst(self.filename)