]> code.delx.au - pymsnt/blobdiff - src/housekeep.py
If parsing of MSNOBJ fails, then don't throw an exception.
[pymsnt] / src / housekeep.py
index ee939a0edfcd1faf99faa65fa487ae30b7fc16da..1020481c74bb9f7c51961d585ecd272961f71194 100644 (file)
@@ -1,6 +1,8 @@
 # Copyright 2005 James Bunton <james@delx.cjb.net>
 # Licensed for distribution under the GPL version 2, check COPYING for details
 
+from tlib import xmlw
+
 import utils
 import config
 import xdb
@@ -10,6 +12,8 @@ import os
 import os.path
 
 
+X = os.path.sep
+
 def init():
        global noteList
        global noteListF
@@ -28,8 +32,8 @@ def init():
 
 class NotesToMyself:
        def __init__(self):
-               pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/"
-               self.filename = pre + "/notes_to_myself"
+               pre = os.path.abspath(config.spooldir) + X + config.jid + X
+               self.filename = pre + X + "notes_to_myself"
                self.notes = []
                
                if os.path.exists(self.filename):
@@ -58,14 +62,16 @@ class NotesToMyself:
 
 
 def doSpoolPrepCheck():
-       pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/"
+       pre = os.path.abspath(config.spooldir) + X + config.jid + X
 
        print "Checking spool files and stringprepping any if necessary...",
 
        for file in os.listdir(pre):
                try:
+                       if not os.path.isfile(file):
+                               continue
                        file = xdb.unmangle(file).decode("utf-8")
-                       filej = utils.jid(file).full()
+                       filej = xmlw.jid.intern(file).full()
                        if(file != filej):
                                file = xdb.mangle(file)
                                filej = xdb.mangle(filej)
@@ -84,12 +90,12 @@ def doHashDirUpgrade():
        print "Upgrading your XDB structure to use hashed directories for speed...",
 
        # Do avatars...
-       pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/avatars/"
+       pre = os.path.join(os.path.abspath(config.spooldir), config.jid) + X + "avatars" + X
        if os.path.exists(pre):
                for file in os.listdir(pre):
                        try:
                                if os.path.isfile(pre + file):
-                                       pre2 = pre + file[0:3] + "/"
+                                       pre2 = pre + file[0:3] + X
                                        if not os.path.exists(pre2):
                                                os.makedirs(pre2)
                                        shutil.move(pre + file, pre2 + file)
@@ -98,13 +104,13 @@ def doHashDirUpgrade():
                                raise
        
        # Do spool files...
-       pre = os.path.abspath(config.spooldir) + "/" + config.jid + "/"
+       pre = os.path.join(os.path.abspath(config.spooldir), config.jid) + X
        if os.path.exists(pre):
                for file in os.listdir(pre):
                        try:
                                if os.path.isfile(pre + file) and file != "notes_to_myself":
                                        hash = file[0:2]
-                                       pre2 = pre + hash + "/"
+                                       pre2 = pre + hash + X
                                        if not os.path.exists(pre2):
                                                os.makedirs(pre2)