24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
|
** This file contains code used to push, pull, and sync a repository
*/
#include "config.h"
#include "sync.h"
#include <assert.h>
/*
** Determine if an autosync should be done or not. The config setting,
** autosync must start with 1, y or Y. The last-sync-url must also be
** defined.
** If the respository is configured for autosyncing, then do an
** autosync. This will be a pull if the argument is true or a push
** if the argument is false. Return true if the autosync is done
** and false if autosync is not requested for the current repository.
*/
int do_autosync(void){
const char *zAutoSync = db_global_get("autosync", 0);
if( zAutoSync != 0
int autosync(int pullFlag){
const char *zUrl;
if( db_get_int("autosync", 0)==0 ){
&& (zAutoSync[0]=='1' || zAutoSync[0]=='y' || zAutoSync=='Y')
&& db_get("last-sync-url", 0)!=0 ){
return 1;
return 0;
}
zUrl = db_get("last-sync-url", 0);
if( zUrl ){
return 0; /* No default server */
}
url_parse(zUrl);
if( g.urlIsFile ){
return 0; /* Network sync only */
}
if( g.urlPort!=80 ){
printf("Autosync: http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
}else{
return 0;
printf("Autosync: http://%s%s\n", g.urlName, g.urlPath);
}
client_sync(!pullFlag, pullFlag, 0);
return 1;
}
/*
** This routine processes the command-line argument for push, pull,
** and sync. If a command-line argument is given, that is the URL
** of a server to sync against. If no argument is given, use the
** most recently synced URL. Remember the current URL for next time.
|