Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Commit c4485fd

Browse files
committed
store reported repos
1 parent 0a327f8 commit c4485fd

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
[![Build Status](https://travis-ci.org/ovsoinc/gitbackup.svg?branch=master)](https://travis-ci.org/ovsoinc/gitbackup) [![Coverage Status](https://coveralls.io/repos/github/ovsoinc/gitbackup/badge.svg?branch=master)](https://coveralls.io/github/ovsoinc/gitbackup?branch=master)
44

5-
We backup and archive GitHub.
5+
> We backup and archive GitHub.
6+
7+
GitBackup was built at [Storj](https://storj.io/) by @super3, @montyanderson, and @calebcase.
68

79
## Design
810

11+
We have a single central server exposing a REST API used by both the user interface and by workers.
12+
13+
Workers operate statelessly and can be scaled, limited only by the central server's ability to provision work.
14+
915
Storj serves as our durable store for all data and metadata. Redis will serve
1016
as the store for ephmerical data and data cached for speed reasons.
1117

server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ router.post('/lock/:username/complete', async ctx => {
215215
.del(`user:${ctx.params.username}:error`)
216216
.exec();
217217

218-
const {totalRepos, storageDelta} = ctx.query;
218+
const {totalRepos, reportedRepos, storageDelta} = ctx.query;
219219
const oldTotal = await redis.getset(`user:${ctx.params.username}`, totalRepos) || 0;
220220

221221
await redis.multi()
222+
.set(`user:${ctx.params.username}:reported-repos`, reportedRepos)
222223
.decrby('stats:repos', Number(oldTotal))
223224
.incrby('stats:repos', Number(totalRepos))
224225
.incrby('stats:storage', Number(storageDelta))

worker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ async function storjSize(path) {
112112
async function cloneUser({ username, lastSynced }) {
113113
// get list of repositories from Github API
114114
const repos = await getRepos({ username });
115+
const reportedRepos = repos.length;
116+
115117
let storageDelta = 0;
116118
let totalUpload = 0;
117119

@@ -212,6 +214,7 @@ async function cloneUser({ username, lastSynced }) {
212214

213215
return {
214216
totalRepos,
217+
reportedRepos,
215218
storageDelta,
216219
totalUpload
217220
};
@@ -247,6 +250,7 @@ async function cloneUser({ username, lastSynced }) {
247250
// sync user
248251
const {
249252
totalRepos,
253+
reportedRepos,
250254
storageDelta,
251255
totalUpload
252256
} = await (async () => {
@@ -269,6 +273,7 @@ async function cloneUser({ username, lastSynced }) {
269273
await lockClient.post(`/lock/${username}/complete`, null, {
270274
params: {
271275
totalRepos,
276+
reportedRepos,
272277
storageDelta
273278
}
274279
});

0 commit comments

Comments
 (0)