From d5874c0bfcefc74ad9045efe4ed8450039b11b9a Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 26 Jul 2011 14:04:02 -0400 Subject: use md5sum as the unique identifier rather than base64 base64 encode will grow with the size of the url, possibly resulting in silly-long filenames. md5sum will keep it to a constant length. --- cloudinit/UserDataHandler.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cloudinit/UserDataHandler.py') diff --git a/cloudinit/UserDataHandler.py b/cloudinit/UserDataHandler.py index fa8ce716..9670c0cb 100644 --- a/cloudinit/UserDataHandler.py +++ b/cloudinit/UserDataHandler.py @@ -24,6 +24,7 @@ from email import encoders import yaml import cloudinit import cloudinit.util as util +import md5 starts_with_mappings={ '#include' : 'text/x-include-url', @@ -49,7 +50,6 @@ def decomp_str(str): def do_include(str,parts): import urllib import os - import base64 # is just a list of urls, one per line # also support '#include ' includeonce = False @@ -66,8 +66,10 @@ def do_include(str,parts): if line.startswith("#"): continue # urls cannot not have leading or trailing white space - uniquestring = base64.encodestring(line).strip() - includeonce_filename = "%s/urlcache/%s" % (cloudinit.get_ipath_cur("data"), uniquestring) + msum = md5.new() + msum.update(line.strip()) + includeonce_filename = "%s/urlcache/%s" % ( + cloudinit.get_ipath_cur("data"), msum.hexdigest()) try: if includeonce and os.path.isfile(includeonce_filename): with open(includeonce_filename, "r") as fp: -- cgit v1.2.3