| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ac23db0 commit 325a54c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,7 +225,24 @@ var configuredLimiter = func() *mutablelimiter.Limiter { | |||
| 225 | 225 | return limiter | |
| 226 | 226 | } | |
| 227 | 227 | ||
| 228 | - // UpdateFromDiff updates the scheduled and queued repos from the given sync diff. | ||
| 228 | + // UpdateFromDiff updates the scheduled and queued repos from the given sync | ||
| 229 | + // diff. | ||
| 230 | + // | ||
| 231 | + // We upsert all repos that exist to the scheduler. This is so the | ||
| 232 | + // scheduler can track the repositories and periodically update | ||
| 233 | + // them. | ||
| 234 | + // | ||
| 235 | + // Items on the update queue will be cloned/fetched as soon as | ||
| 236 | + // possible. We treat repos differently depending on which part of the | ||
| 237 | + // diff they are: | ||
| 238 | + // | ||
| 239 | + // | ||
| 240 | + // Deleted - remove from scheduler and queue. | ||
| 241 | + // Added - new repo, enqueue for asap clone. | ||
| 242 | + // Modified - likely new url or name. May also be a sign of new | ||
| 243 | + // commits. Enqueue for asap clone (or fetch). | ||
| 244 | + // Unmodified - we likely already have this cloned. Just rely on | ||
| 245 | + // the scheduler and do not enqueue. | ||
| 229 | 246 | func (s *updateScheduler) UpdateFromDiff(diff Diff) { | |
| 230 | 247 | for _, r := range diff.Deleted { | |
| 231 | 248 | s.remove(r) | |
@@ -262,6 +279,11 @@ func (s *updateScheduler) SetCloned(names []string) { | |||
| 262 | 279 | s.schedule.setCloned(names) | |
| 263 | 280 | } | |
| 264 | 281 | ||
| 282 | + // upsert adds r to the scheduler for periodic updates. If r.ID is already in | ||
| 283 | + // the scheduler, then the fields are updated (upsert). | ||
| 284 | + // | ||
| 285 | + // If enqueue is true then r is also enqueued to the update queue for a git | ||
| 286 | + // fetch/clone soon. | ||
| 265 | 287 | func (s *updateScheduler) upsert(r *Repo, enqueue bool) { | |
| 266 | 288 | repo := configuredRepo2FromRepo(r) | |
| 267 | 289 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -268,13 +268,17 @@ func (s *Syncer) initialUnmodifiedDiffFromStore(ctx context.Context) { | |||
| 268 | 268 | return | |
| 269 | 269 | } | |
| 270 | 270 | ||
| 271 | + // Assuming sources returns no differences from the last sync, the Diff | ||
| 272 | + // would be just a list of all stored repos Unmodified. This is the steady | ||
| 273 | + // state, so is the initial diff we choose. | ||
| 271 | 274 | select { | |
| 272 | 275 | case s.Synced <- Diff{Unmodified: stored}: | |
| 273 | 276 | case <-ctx.Done(): | |
| 274 | 277 | } | |
| 275 | 278 | } | |
| 276 | 279 | ||
| 277 | - // A Diff of two sets of Diffables. | ||
| 280 | + // Diff is the difference found by a sync between what is in the store and | ||
| 281 | + // what is returned from sources. | ||
| 278 | 282 | type Diff struct { | |
| 279 | 283 | Added Repos | |
| 280 | 284 | Deleted Repos | |
| Back | FazBrowse Home | New Git URL |
0 commit comments