diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 9c5d0bab8aaef9c2e5407f42c696e6f67a5a9302..73c09b27442fb3dfa431fc01ef0593851a61a5ed 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -401,6 +401,9 @@ Path addToStore(const Path & _srcPath)
         PathLocks outputLock(lockPaths);
 
         if (!isValidPath(dstPath)) {
+
+            if (pathExists(dstPath)) deletePath(dstPath);
+            
             copyPath(srcPath, dstPath);
 
             Transaction txn(nixDB);
@@ -426,6 +429,9 @@ void addTextToStore(const Path & dstPath, const string & s)
         PathLocks outputLock(lockPaths);
 
         if (!isValidPath(dstPath)) {
+
+            if (pathExists(dstPath)) deletePath(dstPath);
+
             writeStringToFile(dstPath, s);
 
             Transaction txn(nixDB);