[darwinbuild-changes] [849] branches/PR-8116613/darwinup

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 28 15:35:07 PDT 2010


Revision: 849
          http://trac.macosforge.org/projects/darwinbuild/changeset/849
Author:   wsiegrist at apple.com
Date:     2010-06-28 15:35:07 -0700 (Mon, 28 Jun 2010)
Log Message:
-----------
Clean up paths used with rsync so we are even more consistent with rsync, even when given a symlink on the remote end.

Modified Paths:
--------------
    branches/PR-8116613/darwinup/Archive.cpp
    branches/PR-8116613/darwinup/Utils.cpp

Modified: branches/PR-8116613/darwinup/Archive.cpp
===================================================================
--- branches/PR-8116613/darwinup/Archive.cpp	2010-06-28 22:00:03 UTC (rev 848)
+++ branches/PR-8116613/darwinup/Archive.cpp	2010-06-28 22:35:07 UTC (rev 849)
@@ -280,23 +280,14 @@
 			fprintf(stderr, "Error: could not fetch remote URL: %s \n", path);
 			return NULL;
 		}
-	} else if (is_userhost_path(path)) {
-		char* cleanpath;
-		// join with / to ensure all single slashes and a single trailing slash
-		int res = join_path(&cleanpath, path, "/");
-		assert(res==0);
-		size_t pathlen = strlen(cleanpath);
-		// remove trailing slash so rsync behavior is predictable
-		cleanpath[pathlen - 1] = '\0';
-	
-		IF_DEBUG("fetching userhost path from: %s to: %s \n", cleanpath, tmppath);
-		actpath = fetch_userhost(cleanpath, tmppath);
+	} else if (is_userhost_path(path)) {		
+		IF_DEBUG("fetching userhost path from: %s to: %s \n", path, tmppath);
+		actpath = fetch_userhost(path, tmppath);
 		IF_DEBUG("fetched %s \n", actpath);
 		if (!actpath) {
 			fprintf(stderr, "Error: could not fetch remote file from: %s \n", path);
 			return NULL;
 		}
-		free(cleanpath);
 	} else {
 		actpath = (char *)path;
 	}

Modified: branches/PR-8116613/darwinup/Utils.cpp
===================================================================
--- branches/PR-8116613/darwinup/Utils.cpp	2010-06-28 22:00:03 UTC (rev 848)
+++ branches/PR-8116613/darwinup/Utils.cpp	2010-06-28 22:35:07 UTC (rev 849)
@@ -257,30 +257,35 @@
 
 char* fetch_userhost(const char* srcpath, const char* dstpath) {
 	extern uint32_t verbosity;
+	int res = 0;
 
-	char* localfile;
-	int res = join_path(&localfile, dstpath, basename((char*)srcpath));
-	if (!localfile) return NULL;
+	// clean up srcpath by adding trailing slash
+	char* cleansrc;
+	res = join_path(&cleansrc, srcpath, "/");
+	if (res != 0) return NULL;
+
+	// make sure dstpath ends in basename of cleansrc for consistent rsync behavior
+	char* cleandst;
+	char* srccopy = strdup(cleansrc); // basename might modify input, so make a copy
+	res = join_path(&cleandst, dstpath, basename(srccopy));
+	if (res != 0) return NULL;
+
+	IF_DEBUG("rsync -a --delete %s %s %s \n", 
+			 (verbosity ? "-v" : "-q"), cleansrc, cleandst);
 	
-	// make sure dstpath has a trailing slash
-	char* cleanpath;
-	res = join_path(&cleanpath, dstpath, "/");
-	if (!cleanpath) return NULL;
-		
-	IF_DEBUG("rsync %s %s %s \n", (verbosity ? "-v" : "-q"), srcpath, cleanpath);
-	
 	const char* args[] = {
 		"/usr/bin/rsync",
 		(verbosity ? "-v" : "-q"),
 		"-a", "--delete",
-		srcpath,
-		cleanpath,
+		cleansrc,
+		cleandst,
 		NULL
 	};
 
-	free(cleanpath);
 	if (res == 0) res = exec_with_args(args);
-	if (res == 0) return localfile;
+	free(srccopy);
+	free(cleansrc);
+	if (res == 0) return cleandst;
 	return NULL;	
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100628/20d489c9/attachment.html>


More information about the darwinbuild-changes mailing list