Commits

k0s  committed 76b4955

[svn r6999] wrap file mode operations in try except, fixes #6135

  • Participants
  • Parent commits c87c949

Comments (0)

Files changed (2)

File 0.11/repository_hook_system/filesystemhooks.py

         """create the stub for given hook and return the file object"""
         
         filename = self.filename(hookname)
-        os.mknod(filename, self.mode)
+        try:
+            os.mknod(filename, self.mode)
+        except: # won't work on windows
+            pass
         f = file(filename, 'w')
         print >> f, "#!/bin/bash"
         return f

File 0.11/repository_hook_system/svnhooksystem.py

 from trac.core import *
 from trac.util.text import CRLF
 from trac.versioncontrol import NoSuchChangeset
+from trac.web.chrome import add_warning
 from utils import iswritable
 
 class SVNHookSystem(FileSystemHooks):
         filename = self.filename(hookname)
         if not os.path.exists(filename):
             if not iswritable(filename):
-                return # XXX error handling?
-            os.mknod(self.mode)
+                add_warning(req, 'File "%s" not writable' % filename)
+                return
         f = file(filename, 'w')
         print >> f, contents
+        f.close()
+        try:
+            os.chmod(filename, self.mode)
+        except: # won't work on winblows
+            pass
 
     ### methods for IRepositoryChangeListener