Fossil SCM

Abort a clone and delete the new repository if the server for the clone returns an error during the sync.

drh 2010-12-20 02:02 trunk
Commit f6263ed6ce5fb60f8a11abab87d072199e9eac82
1 file changed +6 -1
+6 -1
--- src/clone.c
+++ src/clone.c
@@ -41,10 +41,11 @@
4141
**
4242
*/
4343
void clone_cmd(void){
4444
char *zPassword;
4545
const char *zDefaultUser; /* Optional name of the default user */
46
+ int nErr = 0;
4647
4748
url_proxy_options();
4849
if( g.argc < 4 ){
4950
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
5051
}
@@ -93,15 +94,19 @@
9394
"REPLACE INTO config(name,value)"
9495
" VALUES('server-code', lower(hex(randomblob(20))));"
9596
);
9697
url_enable_proxy(0);
9798
g.xlinkClusterOnly = 1;
98
- client_sync(0,0,1,CONFIGSET_ALL,0);
99
+ nErr = client_sync(0,0,1,CONFIGSET_ALL,0);
99100
g.xlinkClusterOnly = 0;
100101
verify_cancel();
101102
db_end_transaction(0);
102103
db_close();
104
+ if( nErr ){
105
+ unlink(g.argv[3]);
106
+ fossil_fatal("server returned an error - clone aborted");
107
+ }
103108
db_open_repository(g.argv[3]);
104109
}
105110
db_begin_transaction();
106111
printf("Rebuilding repository meta-data...\n");
107112
rebuild_db(0, 1);
108113
--- src/clone.c
+++ src/clone.c
@@ -41,10 +41,11 @@
41 **
42 */
43 void clone_cmd(void){
44 char *zPassword;
45 const char *zDefaultUser; /* Optional name of the default user */
 
46
47 url_proxy_options();
48 if( g.argc < 4 ){
49 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
50 }
@@ -93,15 +94,19 @@
93 "REPLACE INTO config(name,value)"
94 " VALUES('server-code', lower(hex(randomblob(20))));"
95 );
96 url_enable_proxy(0);
97 g.xlinkClusterOnly = 1;
98 client_sync(0,0,1,CONFIGSET_ALL,0);
99 g.xlinkClusterOnly = 0;
100 verify_cancel();
101 db_end_transaction(0);
102 db_close();
 
 
 
 
103 db_open_repository(g.argv[3]);
104 }
105 db_begin_transaction();
106 printf("Rebuilding repository meta-data...\n");
107 rebuild_db(0, 1);
108
--- src/clone.c
+++ src/clone.c
@@ -41,10 +41,11 @@
41 **
42 */
43 void clone_cmd(void){
44 char *zPassword;
45 const char *zDefaultUser; /* Optional name of the default user */
46 int nErr = 0;
47
48 url_proxy_options();
49 if( g.argc < 4 ){
50 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
51 }
@@ -93,15 +94,19 @@
94 "REPLACE INTO config(name,value)"
95 " VALUES('server-code', lower(hex(randomblob(20))));"
96 );
97 url_enable_proxy(0);
98 g.xlinkClusterOnly = 1;
99 nErr = client_sync(0,0,1,CONFIGSET_ALL,0);
100 g.xlinkClusterOnly = 0;
101 verify_cancel();
102 db_end_transaction(0);
103 db_close();
104 if( nErr ){
105 unlink(g.argv[3]);
106 fossil_fatal("server returned an error - clone aborted");
107 }
108 db_open_repository(g.argv[3]);
109 }
110 db_begin_transaction();
111 printf("Rebuilding repository meta-data...\n");
112 rebuild_db(0, 1);
113

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button