<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 10, 2017 at 3:26 PM, Michael Hrivnak <span dir="ltr"><<a href="mailto:mhrivnak@redhat.com" target="_blank">mhrivnak@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Jul 10, 2017 at 3:06 PM, Dennis Kliban <span dir="ltr"><<a href="mailto:dkliban@redhat.com" target="_blank">dkliban@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>The upload API for Artifacts is going to allow users to specify the artifact size and a digest. The Artifact model currently supports  'md5', 'sha1', 'sha224', 'sha256', 'sha384', and 'sha512' digests.<br><br></div>Do we want to let users specify more than one digest per upload? e.g. md5 and sha256? <br></div></div></blockquote><div><br></div></span><div>There may be no harm in this, but it would add complexity to the verification and not add much value. I'd stick with just one unless there's a compelling reason for multiple.</div><span class=""><div></div></span></div></div></div></blockquote><div><br></div><div>I agree. The API is going to raise a validation exception when more than 1 digest is provided.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div>Do we want to store all 6 digests for each Artifact? </div></blockquote><div><br></div></span><div>The expensive part of calculating the digests is reading the file. As long as you're already reading the entire file, which we will during verification, you may as well stuff the bits through multiple hashers (digesters?) and get all the digests. Pulp 2 has a function that does this:</div><div><br></div><div><a href="https://github.com/pulp/pulp/blob/2.13-release/server/pulp/server/util.py#L327-L353" target="_blank">https://github.com/pulp/pulp/<wbr>blob/2.13-release/server/pulp/<wbr>server/util.py#L327-L353</a><br></div><div><br></div><div>But we can't always guarantee that we'll have all the checksums available, for at least two reasons. 1) If in the future if we want to use yet another algorithm, we probably won't want to run a migration that re-reads every file and calculates the additional digest. 2) For on-demand content, we don't have it locally, so we can't calculate any additional checksums until it gets fetched.</div><div><br></div><div>So this may be one of those times where we use a good-ole-fashioned getter method that returns the requested digest if it's on the artifact, calculates it if not, or raises an exception if the value isn't available and can't be calculated.</div></div></div></div></blockquote><div><br></div><div>For uploaded Artifacts, all of the digests will be calculated as the file is being processed during the upload. So I don't think calculating all of them should incur significantly more cost than just one. The code snippet from Pulp 2 looks similar to what I am doing. <br><br></div><div>I haven't given much thought to the getter, but your idea sounds fine to me. <br></div><div><br></div><div>Thanks,<br></div><div>Dennis<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_-214906315854289791gmail_signature"><div dir="ltr"><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"><span style="margin:0px;padding:0px">Michael</span> <span style="margin:0px;padding:0px">Hrivnak</span></p><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"></p><span style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"><span style="margin:0px;padding:0px">Principal Software Engineer</span><span style="margin:0px;padding:0px">, <span style="margin:0px;padding:0px">RHCE</span></span> </span><span style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px"></span><br style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px"><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px;padding:0px">Red Hat</p></div></div>
</font></span></div></div>
</blockquote></div><br></div></div>