Author: andar

Revision: 5434

Log:
        Write out the new auth file right away and do not re-read the file if 
doing so

Diff:
Modified: trunk/deluge/core/authmanager.py
===================================================================
--- trunk/deluge/core/authmanager.py    2009-07-01 13:56:36 UTC (rev 5433)
+++ trunk/deluge/core/authmanager.py    2009-07-02 03:48:03 UTC (rev 5434)
@@ -33,7 +33,7 @@
 #
 #
 
-import os.path
+import os
 import random
 import stat
 
@@ -101,12 +101,19 @@
         auth_file = configmanager.get_config_dir("auth")
         # Check for auth file and create if necessary
         if not os.path.exists(auth_file):
-            open(auth_file, "w").write(self.__create_localclient_account())
+            localclient = self.__create_localclient_account()
+            fd = open(auth_file, "w")
+            fd.write(localclient)
+            fd.flush()
+            os.fsync(fd.fileno())
+            fd.close()
             # Change the permissions on the file so only this user can 
read/write it
             os.chmod(auth_file, stat.S_IREAD | stat.S_IWRITE)
+            f = [localclient]
+        else:
+            # Load the auth file into a dictionary: {username: password, ...}
+            f = open(auth_file, "r").readlines()
 
-        # Load the auth file into a dictionary: {username: password, ...}
-        f = open(auth_file, "r")
         for line in f:
             if line.startswith("#"):
                 # This is a comment line
@@ -128,6 +135,5 @@
 
             self.__auth[username.strip()] = (password.strip(), level)
 
-        f.close()
         if "localclient" not in self.__auth:
             open(auth_file, "a").write(self.__create_localclient_account())



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to