2 new revisions:

Revision: 034564ac4622
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Fri Nov  1 11:26:45 2013 UTC
Log:      Issue 1502: more atomic copy operation
http://code.google.com/p/robotframework/source/detail?r=034564ac4622

Revision: 1a6fd4a22a03
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Fri Nov  1 11:27:15 2013 UTC
Log:      merge
http://code.google.com/p/robotframework/source/detail?r=1a6fd4a22a03

==============================================================================
Revision: 034564ac4622
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Fri Nov  1 11:26:45 2013 UTC
Log:      Issue 1502: more atomic copy operation
http://code.google.com/p/robotframework/source/detail?r=034564ac4622

Modified:
 /rundevel.sh
 /src/robot/libraries/OperatingSystem.py

=======================================
--- /rundevel.sh        Thu Dec 20 07:59:58 2012 UTC
+++ /rundevel.sh        Fri Nov  1 11:26:45 2013 UTC
@@ -1,3 +1,3 @@
 #!/bin/bash
 base=`dirname $0`
-ROBOT_SYSLOG_FILE=$base/tmp/syslog.txt python $base/src/robot/run.py -P $base/atest/testresources/testlibs -P $base/tmp -L debug -d $base/tmp "$@" +ROBOT_SYSLOG_FILE=$base/tmp/syslog.txt coverage run $base/src/robot/run.py -P $base/atest/testresources/testlibs -P $base/tmp -L debug -d $base/tmp "$@"
=======================================
--- /src/robot/libraries/OperatingSystem.py     Thu Jun  6 14:00:44 2013 UTC
+++ /src/robot/libraries/OperatingSystem.py     Fri Nov  1 11:26:45 2013 UTC
@@ -14,6 +14,7 @@

 import os
 import sys
+import tempfile
 import time
 import glob
 import fnmatch
@@ -747,16 +748,22 @@
             raise RuntimeError("Source file '%s' does not exist" % source)
         if not os.path.isfile(source):
raise RuntimeError("Source file '%s' is not a regular file" % source)
+        parent = self._destination_directory(dest, dest_is_dir)
         if not os.path.exists(dest):
-            if dest_is_dir:
-                parent = dest
-            else:
-                parent = os.path.dirname(dest)
             if not os.path.exists(parent):
                 os.makedirs(parent)
-        shutil.copy(source, dest)
+ temp_directory = tempfile.mkdtemp(dir=parent) # Temporary directory can be atomically created
+        temp_file = os.path.join(temp_directory, os.path.basename(source))
+        shutil.copy(source, temp_file)
+        shutil.move(temp_file, dest)
+        os.rmdir(temp_directory)
         return source, dest

+    def _destination_directory(self, destination, dest_is_dir):
+        if dest_is_dir:
+            return destination
+        return os.path.dirname(destination)
+
     def copy_directory(self, source, destination):
         """Copies the source directory into the destination.


==============================================================================
Revision: 1a6fd4a22a03
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Fri Nov  1 11:27:15 2013 UTC
Log:      merge
http://code.google.com/p/robotframework/source/detail?r=1a6fd4a22a03


--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to