Commits

dirkbaechle committed fa2fde7

- fixed issue #2720, applied final patch (v3) by Alexey Klimkin

Comments (0)

Files changed (3)

src/engine/SCons/Node/__init__.py

         self.precious = None
         self.noclean = 0
         self.nocache = 0
+        self.cached = 0 # is this node pulled from cache?
         self.always_build = None
         self.includes = None
         self.attributes = self.Attrs() # Generic place to stick information about the Node.

src/engine/SCons/Taskmaster.py

         if T: T.write(self.trace_message(u'Task.execute()', self.node))
 
         try:
-            everything_was_cached = 1
+            cached_targets = []
             for t in self.targets:
-                if t.retrieve_from_cache():
-                    # Call the .built() method without calling the
-                    # .push_to_cache() method, since we just got the
-                    # target from the cache and don't need to push
-                    # it back there.
-                    t.set_state(NODE_EXECUTED)
-                    t.built()
-                else:
-                    everything_was_cached = 0
+                if not t.retrieve_from_cache():
                     break
-            if not everything_was_cached:
+                cached_targets.append(t)
+            if len(cached_targets) < len(self.targets):
+                # Remove targets before building. It's possible that we
+                # partially retrieved targets from the cache, leaving
+                # them in read-only mode. That might cause the command
+                # to fail.
+                #
+                for t in cached_targets:
+                    try:
+                        t.fs.unlink(t.path)
+                    except (IOError, OSError):
+                        pass
                 self.targets[0].build()
+            else:
+                for t in cached_targets:
+                    t.cached = 1
         except SystemExit:
             exc_value = sys.exc_info()[1]
             raise SCons.Errors.ExplicitExit(self.targets[0], exc_value.code)
                 for side_effect in t.side_effects:
                     side_effect.set_state(NODE_NO_STATE)
                 t.set_state(NODE_EXECUTED)
-                t.push_to_cache()
+                if not t.cached:
+                    t.push_to_cache()
                 t.built()
             t.visited()
 

src/engine/SCons/TaskmasterTests.py

         global built_text
         built_text = self.name + " built"
 
+    def remove(self):
+        pass
+
     def built(self):
         global built_text
         if not self.cached:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.