181 |
elif dest_rorp: |
elif dest_rorp: |
182 |
dest_sig = dest_rorp.getRORPath() |
dest_sig = dest_rorp.getRORPath() |
183 |
if dest_rorp.isreg(): |
if dest_rorp.isreg(): |
184 |
dest_rp = dest_base_rpath.new_index(index) |
sig_fp = cls.get_one_sig_fp(dest_base_rpath.new_index(index)) |
185 |
if not dest_rp.isreg(): |
if sig_fp is None: return None |
186 |
log.ErrorLog.write_if_open("UpdateError", dest_rp, |
dest_sig.setfile(sig_fp) |
|
"File changed from regular file before signature") |
|
|
return None |
|
|
dest_sig.setfile(Rdiff.get_signature(dest_rp)) |
|
187 |
else: dest_sig = rpath.RORPath(index) |
else: dest_sig = rpath.RORPath(index) |
188 |
return dest_sig |
return dest_sig |
189 |
|
|
190 |
|
def get_one_sig_fp(cls, dest_rp): |
191 |
|
"""Return a signature fp of given index, corresponding to reg file""" |
192 |
|
if not dest_rp.isreg(): |
193 |
|
log.ErrorLog.write_if_open("UpdateError", dest_rp, |
194 |
|
"File changed from regular file before signature") |
195 |
|
return None |
196 |
|
if Globals.process_uid != 0 and not dest_rp.readable(): |
197 |
|
# This branch can happen with root source and non-root |
198 |
|
# destination. Permissions are changed permanently, which |
199 |
|
# should propogate to the diffs |
200 |
|
assert dest_rp.isowner(), 'no ownership of %s' % (dest_rp.path,) |
201 |
|
dest_rp.chmod(0400 | dest_rp.getperms()) |
202 |
|
return Rdiff.get_signature(dest_rp) |
203 |
|
|
204 |
def patch(cls, dest_rpath, source_diffiter, start_index = ()): |
def patch(cls, dest_rpath, source_diffiter, start_index = ()): |
205 |
"""Patch dest_rpath with an rorpiter of diffs""" |
"""Patch dest_rpath with an rorpiter of diffs""" |
206 |
ITR = rorpiter.IterTreeReducer(PatchITRB, [dest_rpath, cls.CCPP]) |
ITR = rorpiter.IterTreeReducer(PatchITRB, [dest_rpath, cls.CCPP]) |