Fossil SCM
Change the schema for the synclog table so that there are separate rows for transfers in each direction.
Commit
1ec46849ff5e065f9edc1469c09ee95ad4e5b58c8353e5055c3c4e83d9008f1c
Parent
94709e8ed24f09c…
2 files changed
+2
-4
+14
-19
+2
-4
| --- src/schema.c | ||
| +++ src/schema.c | ||
| @@ -628,14 +628,12 @@ | ||
| 628 | 628 | */ |
| 629 | 629 | static const char zSynclogSchema[] = |
| 630 | 630 | @ CREATE TABLE repository.synclog( |
| 631 | 631 | @ sfrom TEXT, -- Sync client. "self" means this repo |
| 632 | 632 | @ sto TEXT, -- Sync server |
| 633 | -@ spush DATETIME, -- Time of last push (julian day) | |
| 634 | -@ spull DATETIME, -- Time of last pull (julian day) | |
| 635 | -@ sdist INT, -- Distance from this repo. 0 means self | |
| 636 | -@ stype TEXT, -- Type of "sto". ex: "git","backup". NULL means fossil | |
| 633 | +@ stime DATETIME, -- Time of transfer (julian day) | |
| 634 | +@ stype TEXT, -- "push", "pull", "git", "backup", "import", etc... | |
| 637 | 635 | @ PRIMARY KEY(sfrom,sto) |
| 638 | 636 | @ ) WITHOUT ROWID; |
| 639 | 637 | ; |
| 640 | 638 | |
| 641 | 639 | /* Create the forum-post schema if it does not already exist */ |
| 642 | 640 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -628,14 +628,12 @@ | |
| 628 | */ |
| 629 | static const char zSynclogSchema[] = |
| 630 | @ CREATE TABLE repository.synclog( |
| 631 | @ sfrom TEXT, -- Sync client. "self" means this repo |
| 632 | @ sto TEXT, -- Sync server |
| 633 | @ spush DATETIME, -- Time of last push (julian day) |
| 634 | @ spull DATETIME, -- Time of last pull (julian day) |
| 635 | @ sdist INT, -- Distance from this repo. 0 means self |
| 636 | @ stype TEXT, -- Type of "sto". ex: "git","backup". NULL means fossil |
| 637 | @ PRIMARY KEY(sfrom,sto) |
| 638 | @ ) WITHOUT ROWID; |
| 639 | ; |
| 640 | |
| 641 | /* Create the forum-post schema if it does not already exist */ |
| 642 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -628,14 +628,12 @@ | |
| 628 | */ |
| 629 | static const char zSynclogSchema[] = |
| 630 | @ CREATE TABLE repository.synclog( |
| 631 | @ sfrom TEXT, -- Sync client. "self" means this repo |
| 632 | @ sto TEXT, -- Sync server |
| 633 | @ stime DATETIME, -- Time of transfer (julian day) |
| 634 | @ stype TEXT, -- "push", "pull", "git", "backup", "import", etc... |
| 635 | @ PRIMARY KEY(sfrom,sto) |
| 636 | @ ) WITHOUT ROWID; |
| 637 | ; |
| 638 | |
| 639 | /* Create the forum-post schema if it does not already exist */ |
| 640 |
+14
-19
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -111,32 +111,27 @@ | ||
| 111 | 111 | void sync_log_entry( |
| 112 | 112 | int syncFlags, /* Indicates whether a PUSH or PULL or both */ |
| 113 | 113 | const char *zRemote, /* Server with which we push or pull */ |
| 114 | 114 | const char *zType /* Type of sync. NULL for normal */ |
| 115 | 115 | ){ |
| 116 | - const char *zPush; | |
| 117 | - const char *zPull; | |
| 116 | + schema_synclog(); | |
| 118 | 117 | if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){ |
| 119 | - zPull = "julianday()"; | |
| 120 | - }else{ | |
| 121 | - zPull = "NULL"; | |
| 118 | + db_multi_exec( | |
| 119 | + "INSERT INTO repository.synclog(sfrom,sto,stime,stype)" | |
| 120 | + " VALUES(%Q,'this',julianday(),%Q)" | |
| 121 | + " ON CONFLICT DO UPDATE SET stime=julianday()", | |
| 122 | + zRemote, zType | |
| 123 | + ); | |
| 122 | 124 | } |
| 123 | 125 | if( syncFlags & (SYNC_PUSH) ){ |
| 124 | - zPush = "julianday()"; | |
| 125 | - }else{ | |
| 126 | - zPush = "NULL"; | |
| 127 | - } | |
| 128 | - schema_synclog(); | |
| 129 | - db_multi_exec( | |
| 130 | - "INSERT INTO repository.synclog(sfrom,sto,spush,spull,sdist,stype)" | |
| 131 | - " VALUES('self',%Q,%s,%s,0,%Q)" | |
| 132 | - " ON CONFLICT DO UPDATE" | |
| 133 | - " SET spush=coalesce(%s,spush)," | |
| 134 | - " spull=coalesce(%s,spull);", | |
| 135 | - zRemote, zPush/*safe-for-%s*/, zPull/*safe-for-%s*/, zType, | |
| 136 | - zPush/*safe-for-%s*/, zPull/*safe-for-%s*/ | |
| 137 | - ); | |
| 126 | + db_multi_exec( | |
| 127 | + "INSERT INTO repository.synclog(sfrom,sto,stime,stype)" | |
| 128 | + " VALUES('this',%Q,julianday(),%Q)" | |
| 129 | + " ON CONFLICT DO UPDATE SET stime=julianday()", | |
| 130 | + zRemote, zType | |
| 131 | + ); | |
| 132 | + } | |
| 138 | 133 | } |
| 139 | 134 | |
| 140 | 135 | |
| 141 | 136 | /* |
| 142 | 137 | ** If the repository is configured for autosyncing, then do an |
| 143 | 138 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -111,32 +111,27 @@ | |
| 111 | void sync_log_entry( |
| 112 | int syncFlags, /* Indicates whether a PUSH or PULL or both */ |
| 113 | const char *zRemote, /* Server with which we push or pull */ |
| 114 | const char *zType /* Type of sync. NULL for normal */ |
| 115 | ){ |
| 116 | const char *zPush; |
| 117 | const char *zPull; |
| 118 | if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){ |
| 119 | zPull = "julianday()"; |
| 120 | }else{ |
| 121 | zPull = "NULL"; |
| 122 | } |
| 123 | if( syncFlags & (SYNC_PUSH) ){ |
| 124 | zPush = "julianday()"; |
| 125 | }else{ |
| 126 | zPush = "NULL"; |
| 127 | } |
| 128 | schema_synclog(); |
| 129 | db_multi_exec( |
| 130 | "INSERT INTO repository.synclog(sfrom,sto,spush,spull,sdist,stype)" |
| 131 | " VALUES('self',%Q,%s,%s,0,%Q)" |
| 132 | " ON CONFLICT DO UPDATE" |
| 133 | " SET spush=coalesce(%s,spush)," |
| 134 | " spull=coalesce(%s,spull);", |
| 135 | zRemote, zPush/*safe-for-%s*/, zPull/*safe-for-%s*/, zType, |
| 136 | zPush/*safe-for-%s*/, zPull/*safe-for-%s*/ |
| 137 | ); |
| 138 | } |
| 139 | |
| 140 | |
| 141 | /* |
| 142 | ** If the repository is configured for autosyncing, then do an |
| 143 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -111,32 +111,27 @@ | |
| 111 | void sync_log_entry( |
| 112 | int syncFlags, /* Indicates whether a PUSH or PULL or both */ |
| 113 | const char *zRemote, /* Server with which we push or pull */ |
| 114 | const char *zType /* Type of sync. NULL for normal */ |
| 115 | ){ |
| 116 | schema_synclog(); |
| 117 | if( syncFlags & (SYNC_PULL|SYNC_CLONE) ){ |
| 118 | db_multi_exec( |
| 119 | "INSERT INTO repository.synclog(sfrom,sto,stime,stype)" |
| 120 | " VALUES(%Q,'this',julianday(),%Q)" |
| 121 | " ON CONFLICT DO UPDATE SET stime=julianday()", |
| 122 | zRemote, zType |
| 123 | ); |
| 124 | } |
| 125 | if( syncFlags & (SYNC_PUSH) ){ |
| 126 | db_multi_exec( |
| 127 | "INSERT INTO repository.synclog(sfrom,sto,stime,stype)" |
| 128 | " VALUES('this',%Q,julianday(),%Q)" |
| 129 | " ON CONFLICT DO UPDATE SET stime=julianday()", |
| 130 | zRemote, zType |
| 131 | ); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | |
| 136 | /* |
| 137 | ** If the repository is configured for autosyncing, then do an |
| 138 |