1+ import type { ContextCancellable } from '@matrixai/contexts' ;
12import type {
23 CapabilityList ,
34 Reference ,
@@ -10,7 +11,6 @@ import { Buffer } from 'buffer';
1011import git from 'isomorphic-git' ;
1112import * as gitUtils from './utils' ;
1213import * as utils from '../utils' ;
13- import { ContextCancellable } from "@matrixai/contexts" ;
1414
1515/**
1616 * Reference discovery
@@ -111,15 +111,18 @@ import {ContextCancellable} from "@matrixai/contexts";
111111 *
112112 * `referenceList` is called for generating the `ref_list` stage.
113113 */
114- async function * advertiseRefGenerator ( {
115- efs,
116- dir,
117- gitDir,
118- } : {
119- efs : EncryptedFS ;
120- dir : string ;
121- gitDir : string ;
122- } , ctx : ContextCancellable ) : AsyncGenerator < Buffer , void , void > {
114+ async function * advertiseRefGenerator (
115+ {
116+ efs,
117+ dir,
118+ gitDir,
119+ } : {
120+ efs : EncryptedFS ;
121+ dir : string ;
122+ gitDir : string ;
123+ } ,
124+ ctx : ContextCancellable ,
125+ ) : AsyncGenerator < Buffer , void , void > {
123126 // Providing side-band-64, symref for the HEAD and agent name capabilities
124127 const capabilityList = [
125128 gitUtils . SIDE_BAND_64_CAPABILITY ,
@@ -131,11 +134,14 @@ async function* advertiseRefGenerator({
131134 } ) ,
132135 gitUtils . AGENT_CAPABILITY ,
133136 ] ;
134- const objectGenerator = gitUtils . listReferencesGenerator ( {
135- efs,
136- dir,
137- gitDir,
138- } , ctx ) ;
137+ const objectGenerator = gitUtils . listReferencesGenerator (
138+ {
139+ efs,
140+ dir,
141+ gitDir,
142+ } ,
143+ ctx ,
144+ ) ;
139145
140146 // PKT-LINE("# service=$servicename" LF)
141147 yield packetLineBuffer ( gitUtils . REFERENCE_DISCOVERY_HEADER ) ;
@@ -344,34 +350,43 @@ async function parsePackRequest(
344350 * It will respond with the `PKT-LINE(NAK_BUFFER)` and then the `packFile` data chunked into lines for the stream.
345351 *
346352 */
347- async function * generatePackRequest ( {
348- efs,
349- dir,
350- gitDir,
351- body,
352- } : {
353- efs : EncryptedFS ;
354- dir : string ;
355- gitDir : string ;
356- body : Array < Buffer > ;
357- } , ctx : ContextCancellable ) : AsyncGenerator < Buffer , void , void > {
358- const [ wants , haves , _capabilities ] = await parsePackRequest ( body ) ;
359- const objectIds = await gitUtils . listObjects ( {
360- efs : efs ,
353+ async function * generatePackRequest (
354+ {
355+ efs,
361356 dir,
362- gitDir : gitDir ,
363- wants,
364- haves,
365- } , ctx ) ;
357+ gitDir,
358+ body,
359+ } : {
360+ efs : EncryptedFS ;
361+ dir : string ;
362+ gitDir : string ;
363+ body : Array < Buffer > ;
364+ } ,
365+ ctx : ContextCancellable ,
366+ ) : AsyncGenerator < Buffer , void , void > {
367+ const [ wants , haves , _capabilities ] = await parsePackRequest ( body ) ;
368+ const objectIds = await gitUtils . listObjects (
369+ {
370+ efs : efs ,
371+ dir,
372+ gitDir : gitDir ,
373+ wants,
374+ haves,
375+ } ,
376+ // ctx,
377+ ) ;
366378 // Reply that we have no common history and that we need to send everything
367379 yield packetLineBuffer ( gitUtils . NAK_BUFFER ) ;
368380 // Send everything over in pack format
369- yield * generatePackData ( {
370- efs : efs ,
371- dir,
372- gitDir,
373- objectIds,
374- } , ctx ) ;
381+ yield * generatePackData (
382+ {
383+ efs : efs ,
384+ dir,
385+ gitDir,
386+ objectIds,
387+ } ,
388+ ctx ,
389+ ) ;
375390 // Send dummy progress data
376391 yield packetLineBuffer (
377392 gitUtils . DUMMY_PROGRESS_BUFFER ,
@@ -387,19 +402,22 @@ async function* generatePackRequest({
387402 * The `packFile` is chunked into the `packetLineBuffer` with the size defined by `chunkSize`.
388403 *
389404 */
390- async function * generatePackData ( {
391- efs,
392- dir,
393- gitDir,
394- objectIds,
395- chunkSize = gitUtils . PACK_CHUNK_SIZE ,
396- } : {
397- efs : EncryptedFS ;
398- dir : string ;
399- gitDir : string ;
400- objectIds : Array < ObjectId > ;
401- chunkSize ?: number ;
402- } , ctx : ContextCancellable ) : AsyncGenerator < Buffer , void , void > {
405+ async function * generatePackData (
406+ {
407+ efs,
408+ dir,
409+ gitDir,
410+ objectIds,
411+ chunkSize = gitUtils . PACK_CHUNK_SIZE ,
412+ } : {
413+ efs : EncryptedFS ;
414+ dir : string ;
415+ gitDir : string ;
416+ objectIds : Array < ObjectId > ;
417+ chunkSize ?: number ;
418+ } ,
419+ ctx : ContextCancellable ,
420+ ) : AsyncGenerator < Buffer , void , void > {
403421 let packFile : PackObjectsResult ;
404422 // In case of errors we don't want to throw them. This will result in the error being thrown into `isometric-git`
405423 // when it consumes the response. It handles this by logging out the error which we don't want to happen.
0 commit comments