diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 33409aeef..a4953b948 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1397,7 +1397,7 @@ void DerivationGoal::startBuilder() /* we check the recalculated state path at build time with the correct user for securiyt */ checkStatePath(drv); - + if(drv.stateOutputs.find("state")->second.getCreateDirsBeforeInstall()) createStateDirs(drv.stateOutputDirs, drv.stateOutputs); } diff --git a/src/libstore/store-state.cc b/src/libstore/store-state.cc index c7f051145..16f2cb1d1 100644 --- a/src/libstore/store-state.cc +++ b/src/libstore/store-state.cc @@ -22,15 +22,13 @@ namespace nix { void updatedStateDerivation(Path storePath) { //We dont remove the old .svn folders - //nothing to do since New repostorys are created by createStateDirs + //update in database? - printMsg(lvlTalkative, format("Resetting state drv settings like repositorys")); - + printMsg(lvlTalkative, format("Resetting state drv settings")); } void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const DerivationStateOutputs & stateOutputs) { - Path statePath = stateOutputs.find("state")->second.statepath; string stateDir = statePath; @@ -51,7 +49,7 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De string thisdir = d.path; - //Check if it is a file + //If it is a file: continue if(thisdir.substr(thisdir.length() -1 , thisdir.length()) != "/") continue; @@ -127,12 +125,10 @@ Snapshots commitStatePathTxn(const Transaction & txn, const Path & statePath) throw Error(format("Type '%1%' is not handled in nix-state") % d.type); //We got here so we need to commit - unsigned int revision_number; - if(pathExists(fullstatedir) || FileExist(fullstatedir)){ revision_number = take_snapshot(fullstatedir); - printMsg(lvlError, format("Snapshotted '%1%' with id '%2%'") % fullstatedir % revision_number); + printMsg(lvlError, format("Snapshotted '%1%@%2%'") % fullstatedir % revision_number); } else revision_number = 0; //deleted, so we assign 0 to indicate that diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc index d55394270..0a0900813 100644 --- a/src/nix-state/nix-state.cc +++ b/src/nix-state/nix-state.cc @@ -277,7 +277,8 @@ static void revertToRevision(Strings opFlags, Strings opArgs) p_args.push_back("-c"); //we use the shell to execute the cp command becuase the shell expands the '*' string cpcommand = "cp -R"; if(revertPathOrFile.substr(revertPathOrFile.length() -1 , revertPathOrFile.length()) == "/"){ //is dir - cpcommand += " " + (revertPathOrFile.substr(0, revertPathOrFile.length() -1) + "@" + unsignedInt2String(epoch) + "/*"); + string revert_to_path = revertPathOrFile.substr(0, revertPathOrFile.length() -1) + "@" + unsignedInt2String(epoch); + cpcommand += " " + revert_to_path + "/*"; //clean all contents of the folder first (so were sure the path is clean) if(pathExists(revertPathOrFile)) @@ -288,6 +289,14 @@ static void revertToRevision(Strings opFlags, Strings opArgs) continue; else ensureDirExists(revertPathOrFile); + + //If the the dir has not contents then a cp ..../* will error since * cannot be expanded. So in this case were done and dont have to revert. + Strings p2_args; + p2_args.push_back("-A"); + p2_args.push_back(revert_to_path + "/"); + string output = runProgram("ls", true, p2_args); + if(output == "") + continue; } else{ //is file cpcommand += " " + (revertPathOrFile + "@" + unsignedInt2String(epoch)); @@ -299,15 +308,11 @@ static void revertToRevision(Strings opFlags, Strings opArgs) continue; } } - - printMsg(lvlError, format("Reverting '%1%'") % revertPathOrFile); + //Revert + printMsg(lvlError, format("Reverting '%1%'") % revertPathOrFile); cpcommand += " " + revertPathOrFile; p_args.push_back(cpcommand); - - //for (Strings::iterator h = p_args.begin(); h != p_args.end(); ++h) - // printMsg(lvlError, format("SH ARGS '%1%'") % *h); - runProgram_AndPrintOutput("sh", true, p_args, "sh-cp"); //TODO does this work on windows? }