1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-27 04:30:59 +01:00

Replaced cp for rsync to copy state

This commit is contained in:
Wouter den Breejen 2007-10-03 09:46:22 +00:00
parent d0458acb7c
commit 43d93e5e64
12 changed files with 53 additions and 45 deletions

View file

@ -15,6 +15,7 @@ string nixLogDir = "/UNINIT";
string nixStateDir = "/UNINIT";
string nixDBPath = "/UNINIT";
string nixExt3CowHeader = "/UNINIT";
string nixRsync = "/UNINIT";
string nixConfDir = "/UNINIT";
string nixLibexecDir = "/UNINIT";
string nixBinDir = "/UNINIT";

View file

@ -30,6 +30,9 @@ extern string nixDBPath;
/* nixExt3CowHeader is the header file used to communicate with ext3cow. */
extern string nixExt3CowHeader;
/* nixRsync is used to copy from one statedir to the other. */
extern string nixRsync;
/* nixConfDir is the directory where configuration files are
stored. */
extern string nixConfDir;

View file

@ -108,7 +108,7 @@ void revertToRevisionTxn(const Transaction & txn, const Path & statePath, const
RevisionClosureTS getTimestamps;
queryStateRevisionsTxn(txn, statePath_ns, getRivisions, getTimestamps, revision_arg);
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//include recursive
//lookup 0 (latest) to the real revision
@ -714,4 +714,34 @@ bool queryAvailableStateRevisions(Database & nixDB, const Transaction & txn, Tab
return true;
}
void copyContents(const Path & from, const Path & to) //TODO bool shellexpansion, bool failure for nix-env
{
//TODO Could be a symlink (to a non-existing dir)
/*
if(!DirectoryExist(from))
throw Error(format("Path `%1%' doenst exist ...") % from);
if(!DirectoryExist(to))
throw Error(format("Path `%1%' doenst exist ...") % to);
*/
//We add a slash / to the end to ensure the contents is copyed
Path from2 = from;
Path to2 = to;
if(from2[from2.length() - 1] != '/')
from2 = from2 + "/";
if(to2[to2.length() - 1] != '/')
to2 = to2 + "/";
printMsg(lvlError, format("Rsync from: '%1%' to: '%2%'") % from2 % to2);
//Rsync from --> to and also with '-avHx --delete'
//This makes the paths completely equal (also deletes) and retains times ownership etc.
Strings p_args;
p_args.push_back("-avHx");
p_args.push_back("--delete");
p_args.push_back(from2);
p_args.push_back(to2);
runProgram_AndPrintOutput(nixRsync, true, p_args, "rsync");
}
}

View file

@ -66,7 +66,9 @@ namespace nix {
/* Returns all available revision numbers of the given state path */
bool queryAvailableStateRevisions(Database & nixDB, const Transaction & txn, TableId revisions_table, TableId revisions_comments,
const Path & statePath, RevisionInfos & revisions);
/* Copy all files and folders recursively (also the hidden ones) from the dir from/... to the dir to/... and delete the rest in to/ (Rsync) */
void copyContents(const Path & from, const Path & to);
}