Fossil SCM
Abort a clone and delete the new repository if the server for the clone returns an error during the sync.
Commit
f6263ed6ce5fb60f8a11abab87d072199e9eac82
Parent
ea61f4aa551df58…
1 file changed
+6
-1
+6
-1
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -41,10 +41,11 @@ | ||
| 41 | 41 | ** |
| 42 | 42 | */ |
| 43 | 43 | void clone_cmd(void){ |
| 44 | 44 | char *zPassword; |
| 45 | 45 | const char *zDefaultUser; /* Optional name of the default user */ |
| 46 | + int nErr = 0; | |
| 46 | 47 | |
| 47 | 48 | url_proxy_options(); |
| 48 | 49 | if( g.argc < 4 ){ |
| 49 | 50 | usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY"); |
| 50 | 51 | } |
| @@ -93,15 +94,19 @@ | ||
| 93 | 94 | "REPLACE INTO config(name,value)" |
| 94 | 95 | " VALUES('server-code', lower(hex(randomblob(20))));" |
| 95 | 96 | ); |
| 96 | 97 | url_enable_proxy(0); |
| 97 | 98 | g.xlinkClusterOnly = 1; |
| 98 | - client_sync(0,0,1,CONFIGSET_ALL,0); | |
| 99 | + nErr = client_sync(0,0,1,CONFIGSET_ALL,0); | |
| 99 | 100 | g.xlinkClusterOnly = 0; |
| 100 | 101 | verify_cancel(); |
| 101 | 102 | db_end_transaction(0); |
| 102 | 103 | db_close(); |
| 104 | + if( nErr ){ | |
| 105 | + unlink(g.argv[3]); | |
| 106 | + fossil_fatal("server returned an error - clone aborted"); | |
| 107 | + } | |
| 103 | 108 | db_open_repository(g.argv[3]); |
| 104 | 109 | } |
| 105 | 110 | db_begin_transaction(); |
| 106 | 111 | printf("Rebuilding repository meta-data...\n"); |
| 107 | 112 | rebuild_db(0, 1); |
| 108 | 113 |
| --- 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 |