[PATCH 2/4] Rename some variables and comments away from md5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We are moving away from using md5 for the uploaded source tarballs, so
the code shouldn't be full of assumption that everything is md5 any
more.
---
 scripts/upload.cgi/upload.cgi | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/scripts/upload.cgi/upload.cgi b/scripts/upload.cgi/upload.cgi
index a43cc6e..00d0988 100644
--- a/scripts/upload.cgi/upload.cgi
+++ b/scripts/upload.cgi/upload.cgi
@@ -57,10 +57,10 @@ def check_auth(username):
         pass
     return authenticated
 
-def send_email(pkg, md5, filename, username):
+def send_email(pkg, checksum, filename, username):
     text = """A file has been added to the lookaside cache for %(pkg)s:
 
-%(md5)s  %(filename)s""" % locals()
+%(checksum)s  %(filename)s""" % locals()
     msg = MIMEText(text)
     try:
         sender_name = pwd.getpwnam(username)[4]
@@ -108,7 +108,7 @@ def main():
 
     form = cgi.FieldStorage()
     name = check_form(form, 'name')
-    md5sum = check_form(form, 'md5sum')
+    checksum = check_form(form, 'md5sum')
 
     action = None
     upload_file = None
@@ -121,7 +121,7 @@ def main():
         action = 'check'
         filename = check_form(form, 'filename')
         filename = os.path.basename(filename)
-        print >> sys.stderr, '[username=%s] Checking file status: NAME=%s FILENAME=%s MD5SUM=%s' % (username, name, filename, md5sum)
+        print >> sys.stderr, '[username=%s] Checking file status: NAME=%s FILENAME=%s CHECKSUM=%s' % (username, name, filename, checksum)
     else:
         action = 'upload'
         if form.has_key('file'):
@@ -131,10 +131,10 @@ def main():
             filename = os.path.basename(upload_file.filename)
         else:
             send_error('Required field "file" is not present.')
-        print >> sys.stderr, '[username=%s] Processing upload request: NAME=%s FILENAME=%s MD5SUM=%s' % (username, name, filename, md5sum)
+        print >> sys.stderr, '[username=%s] Processing upload request: NAME=%s FILENAME=%s CHECKSUM=%s' % (username, name, filename, checksum)
 
     module_dir = os.path.join(CACHE_DIR, name)
-    md5_dir =  os.path.join(module_dir, filename, md5sum)
+    hash_dir =  os.path.join(module_dir, filename, checksum)
 
     # first test if the module really exists
     cvs_dir = os.path.join(CVSREPO, name)
@@ -143,7 +143,7 @@ def main():
         send_error('Module "%s" does not exist!' % name)
 
     # try to see if we already have this file...
-    dest_file = os.path.join(md5_dir, filename)
+    dest_file = os.path.join(hash_dir, filename)
     if os.path.exists(dest_file):
         if action == 'check':
             print 'Available'
@@ -163,7 +163,7 @@ def main():
 
     # grab a temporary filename and dump our file in there
     tempfile.tempdir = module_dir
-    tmpfile = tempfile.mkstemp(md5sum)[1]
+    tmpfile = tempfile.mkstemp(checksum)[1]
     tmpfd = open(tmpfile, 'w')
 
     # now read the whole file in
@@ -177,23 +177,23 @@ def main():
         m.update(data)
         filesize += len(data)
 
-    # now we're done reading, check the MD5 sum of what we got
+    # now we're done reading, check the checksum of what we got
     tmpfd.close()
-    check_md5sum = m.hexdigest()
-    if md5sum != check_md5sum:
-        send_error("MD5 check failed. Received %s instead of %s." % (check_md5sum, md5sum))
+    check_checksum = m.hexdigest()
+    if checksum != check_checksum:
+        send_error("Checksum check failed. Received %s instead of %s." % (check_checksum, checksum))
 
-    # wow, even the MD5SUM matches. make sure full path is valid now
-    if not os.path.isdir(md5_dir):
-        os.makedirs(md5_dir, 02775)
-        print >> sys.stderr, '[username=%s] mkdir %s' % (username, md5_dir)
+    # wow, even the check matches. make sure full path is valid now
+    if not os.path.isdir(hash_dir):
+        os.makedirs(hash_dir, 02775)
+        print >> sys.stderr, '[username=%s] mkdir %s' % (username, hash_dir)
 
     os.rename(tmpfile, dest_file)
     os.chmod(dest_file, 0644)
 
     print >> sys.stderr, '[username=%s] Stored %s (%d bytes)' % (username, dest_file, filesize)
-    print 'File %s size %d MD5 %s stored OK' % (filename, filesize, md5sum)
-    send_email(name, md5sum, filename, username)
+    print 'File %s size %d MD5 %s stored OK' % (filename, filesize, checksum)
+    send_email(name, checksum, filename, username)
 
 if __name__ == '__main__':
     main()
-- 
1.8.5.3

_______________________________________________
infrastructure mailing list
infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/infrastructure





[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux