91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
|
azOther[i] = 0;
}
fossil_free(azOther);
return nErr;
}
/*
** Make a new entry, or update an existing entry, in the SYNCLOG table
** Make a new entry, or update an existing entry, in the SYNCLOG table.
** for a push or pull from this repository to another server named zRemote.
**
** For an ordinary push/pull, zType is NULL. But it may also be a string
** describing non-standard operations. For example zType might be "git"
** when doing a "fossil git export", or zType might be "import" when doing
** a "fossil pull --from-parent-project".
**
** For this routine, the sfrom value is always 'self'. The sto value is
** the zRemote parameter. sto+sfrom form the primary key. If an entry
** already exists with the same primary key, then the spull or spush times
** are updated (or both).
*/
void sync_log_entry(
int syncFlags, /* Indicates whether a PUSH or PULL or both */
const char *zRemote, /* Server with which we push or pull */
const char *zType, /* Type of sync. NULL for normal */
const char *zFrom, /* Content comes from this machine */
const char *zTo, /* Content goes to this machine */
i64 iTime, /* Transfer time, or 0 for "now" */
const char *zType /* Type of sync. NULL for normal */
i64 iTime /* Seconds since 1970, or 0 for "now" */
){
Stmt s;
schema_synclog();
if( iTime<=0 ){
db_prepare(&s,
db_multi_exec(
"INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
" VALUES(:sfrom,:sto,unixepoch(),%Q)"
" VALUES(%Q,%Q,unixepoch(),%Q)"
" ON CONFLICT DO UPDATE SET stime=unixepoch()",
zType
zFrom, zTo, zType
);
}else{
db_prepare(&s,
db_multi_exec(
"INSERT INTO repository.synclog(sfrom,sto,stime,stype)"
" VALUES(:sfrom,:sto,%lld,%Q)"
" VALUES(%Q,%Q,%lld,%Q)"
" ON CONFLICT DO UPDATE SET stime=%lld WHERE stime<%lld",
iTime, zType, iTime, iTime
zFrom, zTo, iTime, zType, iTime, iTime
);
}
if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){
db_bind_text(&s, ":sfrom", zRemote);
db_bind_text(&s, ":sto", "this");
db_step(&s);
db_reset(&s);
}
if( syncFlags & (SYNC_PUSH) ){
db_bind_text(&s, ":sfrom", "this");
db_bind_text(&s, ":sto", zRemote);
db_step(&s);
}
db_finalize(&s);
}
/*
** If the repository is configured for autosyncing, then do an
** autosync. Bits of the "flags" parameter determine details of behavior:
**
|
757
758
759
760
761
762
763
764
765
766
|
738
739
740
741
742
743
744
745
746
747
|
-
+
|
}else{
fossil_fatal("backup \"%s\" already exists", zDest);
}
}
db_unprotect(PROTECT_ALL);
db_multi_exec("VACUUM repository INTO %Q", zDest);
zFullName = file_canonical_name_dup(zDest);
sync_log_entry(SYNC_PUSH, zFullName, "backup", 0);
sync_log_entry("this", zFullName, 0, "backup");
fossil_free(zFullName);
}
|