@@ -111,6 +111,8 @@ async function storjSize(path) {
111
111
112
112
async function cloneUser ( { username, lastSynced } ) {
113
113
// get list of repositories from Github API
114
+ let publicLog = '' ;
115
+
114
116
const repos = await getRepos ( { username } ) ;
115
117
const reportedRepos = repos . length ;
116
118
@@ -136,14 +138,17 @@ async function cloneUser({ username, lastSynced }) {
136
138
const lastUpdated = new Date ( repo . updated_at ) ;
137
139
138
140
log . info ( repo . full_name , { lastUpdated, lastSynced, updated_at : repo . updated_at } ) ;
141
+ publicLog += `${ repo . full_name } ${ JSON . stringify ( { lastUpdated, lastSynced, updated_at : repo . updated_at } ) } \n` ;
139
142
140
143
// skip if repository hasn't been updated since last sync
141
144
if ( lastUpdated < lastSynced ) {
145
+ publicLog += `repository hasn't been updated since last sync. skipping\n` ;
142
146
continue ;
143
147
}
144
148
145
149
// skip if repository is too big
146
150
if ( repo . size > 4250000 ) {
151
+ publicLog += `repository is too big (${ repo . size } ). skipping\n` ;
147
152
continue ;
148
153
}
149
154
@@ -158,6 +163,7 @@ async function cloneUser({ username, lastSynced }) {
158
163
159
164
// Create bundle:
160
165
log . info ( repo . full_name , 'cloning' ) ;
166
+ publicLog += `cloning\n` ;
161
167
162
168
try {
163
169
await execa ( 'git' , [ 'clone' , '--mirror' , repo . git_url , repoPath ] ) ;
@@ -166,11 +172,13 @@ async function cloneUser({ username, lastSynced }) {
166
172
} ) ;
167
173
} catch ( err ) {
168
174
log . info ( repo . full_name , 'clone failed' ) ;
175
+ publicLog += 'clone failed. skipping\n' ;
169
176
continue ;
170
177
}
171
178
172
179
// Download zip:
173
180
log . info ( repo . full_name , 'downloading zip' ) ;
181
+ publicLog += 'downloading zip\n' ;
174
182
175
183
const { data} = await axios . get ( `${ repo . html_url } /archive/master.zip` , {
176
184
responseType : 'stream' ,
@@ -201,6 +209,8 @@ async function cloneUser({ username, lastSynced }) {
201
209
totalUpload += ( await fs . stat ( repoZipPath ) ) . size ;
202
210
203
211
log . info ( repo . full_name , 'cleaning up' ) ;
212
+ publicLog += 'cleaning up\n' ;
213
+
204
214
await execa ( 'rm' , [ '-rf' , repoBundlePath ] ) ;
205
215
await execa ( 'rm' , [ '-rf' , repoZipPath ] ) ;
206
216
await execa ( 'rm' , [ '-rf' , repoPath ] ) ;
@@ -209,6 +219,13 @@ async function cloneUser({ username, lastSynced }) {
209
219
log . info ( repo . full_name , 'done' ) ;
210
220
}
211
221
222
+ const logPath = `${ __dirname } /repos/${ username } .log` ;
223
+ const storjLogPath = `${ pathing . encode ( username ) } .log` ;
224
+
225
+ storageDelta -= await storjSize ( storjLogPath ) ;
226
+ await storjUpload ( logPath , storjLogPath ) ;
227
+ storageDelta += ( await fs . stat ( logPath ) ) . size ;
228
+
212
229
// wait 5 seconds after each user
213
230
await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
214
231
0 commit comments