Rev 16: Move symlink checking out to the pre-check, so we can handle dangling symlinks cleanly too. in http://people.ubuntu.com/~robertc/baz2.0/plugins/avahi/trunk

Robert Collins robertc at robertcollins.net
Mon Jul 9 08:59:52 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/plugins/avahi/trunk

------------------------------------------------------------
revno: 16
revision-id: robertc at robertcollins.net-20070709075951-n1c54rgpuro58gq5
parent: robertc at robertcollins.net-20070709071707-tgrc4a7989zap6rd
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Mon 2007-07-09 17:59:51 +1000
message:
  Move symlink checking out to the pre-check, so we can handle dangling symlinks cleanly too.
modified:
  share.py                       share.py-20070323082617-ua0xkev3o590n4rm-1
=== modified file 'share.py'
--- a/share.py	2007-07-09 07:17:07 +0000
+++ b/share.py	2007-07-09 07:59:51 +0000
@@ -17,6 +17,7 @@
 
 __metaclass__ = type
 
+import os.path
 import stat
 
 import avahi
@@ -151,7 +152,14 @@
         dirs_to_check = ['.']
         while len(dirs_to_check) > 0:
             filename = dirs_to_check.pop(0)
-            if stat.S_ISDIR(trans.stat(filename).st_mode):
+            local_path = trans.local_abspath(filename)
+            file_mode = os.lstat(local_path).st_mode
+            if stat.S_ISLNK(file_mode):
+                # if it was a symlink we don't need to share it or scan it -
+                # either inside the root somewhere else, or its not and
+                # thus not sharable 
+                continue
+            elif stat.S_ISDIR(file_mode):
                 try:
                     bpath = trans.abspath(filename)
                     bdir = bzrdir.BzrDir.open(bpath)
@@ -164,8 +172,7 @@
 
                 if branch is not None and branch.base == bpath + "/":
                     # if the branch was found somewhere else it won't share
-                    # properly: if it was a reference the repo won't be served,
-                    # if it was a symlink a similar problem exists.
+                    # properly: if it was a reference the repo won't be served.
                     trace.mutter("Found branch '%s' (nick %s)"
                                  % (filename, branch.nick))
                     try:




More information about the bazaar-commits mailing list