Fixed permission setting in copyFile 2007-09-13 ghc-6_8_branched_2007-09-03
authorsven.panne@aedion.de <unknown>
Sun, 2 Sep 2007 12:55:21 +0000 (12:55 +0000)
committersven.panne@aedion.de <unknown>
Sun, 2 Sep 2007 12:55:21 +0000 (12:55 +0000)
Copy the permissions to the *temporary* file before moving it, no to the
probably non-existing real destination file. Before this fix, "try" silently
wiped this bug under the carpet, leading to silently broken permissions.

System/Directory.hs

index e7affb6..c3698a2 100644 (file)
@@ -553,7 +553,7 @@ copyFile fromFPath toFPath =
                  bracketOnError openTmp cleanTmp $ \(tmpFPath, hTmp) ->
                  do allocaBytes bufferSize $ copyContents hFrom hTmp
                     hClose hTmp
-                    try (copyPermissions fromFPath toFPath)
+                    try (copyPermissions fromFPath tmpFPath)
                     renameFile tmpFPath toFPath
           openTmp = openBinaryTempFile (takeDirectory toFPath) ".copyFile.tmp"
           cleanTmp (tmpFPath, hTmp) = do try $ hClose hTmp