+ pre = os.path.join(os.path.abspath(config.spooldir), config.jid) + X
+ if os.path.exists(pre + "avatars"):
+ # Remove the avatars dir that gets created when we import
+ # legacy/glue.py (it only contains the defaultAvatar)
+ shutil.rmtree(config.spooldir + X + "avatars")
+ shutil.move(pre + "avatars", config.spooldir + X + "avatars")
+ else:
+ print "Could not move your cached avatars directory automatically. It is safe to delete it, the avatars will be recreated as necessary."
+
+
+ print "Upgrading your spool directory to use md5 hashes."
+
+ dirlist = os.listdir(pre)
+ dir, hash, file = "","",""
+ try:
+ for dir in dirlist:
+ if not os.path.isdir(pre + dir) or dir == "avatars" or len(dir) == 3:
+ continue
+ pre2 = pre + dir + X
+ for file in os.listdir(pre2):
+ if not os.path.isfile(pre2 + file):
+ continue
+ hash = xdb.makeHash(os.path.splitext(file)[0])
+ if not os.path.exists(pre + hash):
+ os.makedirs(pre + hash)
+ shutil.move(pre2 + file, pre + hash + X + file)
+ os.rmdir(dir)
+ except Exception, e:
+ print "Error in migration", pre, dir, hash, file, str(e)
+ sys.exit(1)
+
+
+
+noteList = ["doSpoolPrepCheck", "doHashDirUpgrade", "doMD5HashDirUpgrade"]
+noteListF = [doSpoolPrepCheck, doHashDirUpgrade, doMD5HashDirUpgrade]