@@ -17,6 +17,7 @@ import type { NodeId, NodeIdEncoded } from '../ids/types';
1717import type NodeConnectionManager from '../nodes/NodeConnectionManager' ;
1818import type RPCClient from '../rpc/RPCClient' ;
1919import type { clientManifest as agentClientManifest } from '../agent/handlers/clientManifest' ;
20+ import type { POJO } from '../types' ;
2021import path from 'path' ;
2122import git from 'isomorphic-git' ;
2223import Logger from '@matrixai/logger' ;
@@ -26,11 +27,11 @@ import {
2627} from '@matrixai/async-init/dist/CreateDestroyStartStop' ;
2728import { withF , withG } from '@matrixai/resources' ;
2829import { RWLockWriter } from '@matrixai/async-locks' ;
29- import * as utils from '@/utils' ;
30- import * as validationUtils from '@/validation/utils' ;
3130import * as vaultsErrors from './errors' ;
3231import * as vaultsUtils from './utils' ;
3332import { tagLast } from './types' ;
33+ import * as validationUtils from '../validation/utils' ;
34+ import * as utils from '../utils' ;
3435import * as nodesUtils from '../nodes/utils' ;
3536import { never } from '../utils/utils' ;
3637
@@ -139,7 +140,7 @@ class VaultInternal {
139140
140141 const vaultIdEncoded = vaultsUtils . encodeVaultId ( vaultId ) ;
141142 logger . info ( `Cloning ${ this . name } - ${ vaultIdEncoded } ` ) ;
142- const vault = new VaultInternal ( {
143+ const vault = new this ( {
143144 vaultId,
144145 db,
145146 vaultsDbPath,
@@ -766,13 +767,11 @@ class VaultInternal {
766767 typeof vaultNameOrId === 'string'
767768 ? vaultNameOrId
768769 : vaultsUtils . encodeVaultId ( vaultNameOrId ) ;
769- console . log ( 'a' ) ;
770770 const response = await client . methods . vaultsGitInfoGet ( {
771771 vaultNameOrId : vaultNameOrId_ ,
772772 action : vaultAction ,
773773 } ) ;
774- console . log ( 'a' ) ;
775- console . log ( response . meta ) ;
774+ await response . writable . close ( ) ;
776775
777776 const result = response . meta ?. result ;
778777 if ( result == null || ! utils . isObject ( result ) ) never ( ) ;
@@ -793,7 +792,6 @@ class VaultInternal {
793792 for await ( const chunk of response . readable ) {
794793 infoResponse . push ( chunk ) ;
795794 }
796- // TODO: complete
797795 return [
798796 async function ( {
799797 url,
@@ -818,17 +816,13 @@ class VaultInternal {
818816 } ;
819817 } else if ( method === 'POST' ) {
820818 const responseBuffers : Array < Uint8Array > = [ ] ;
821- const stream = client . methods . vaultsGitPackGet ( metadata ) ;
822- const chunk = new vaultsPB . PackChunk ( ) ;
823- // Body is usually an async generator but in the cases we are using,
824- // only the first value is used
825- chunk . setChunk ( body [ 0 ] ) ;
826- // Tell the server what commit we need
827- await stream . write ( chunk ) ;
828- let packResponse = ( await stream . read ( ) ) . value ;
829- while ( packResponse != null ) {
830- responseBuffers . push ( packResponse . getChunk_asU8 ( ) ) ;
831- packResponse = ( await stream . read ( ) ) . value ;
819+ const stream = await client . methods . vaultsGitPackGet ( {
820+ body : body [ 0 ] . toString ( 'binary' ) ,
821+ nameOrId : result . vaultIdEncoded as string ,
822+ vaultAction,
823+ } ) ;
824+ for await ( const value of stream ) {
825+ responseBuffers . push ( Buffer . from ( value . chunk , 'binary' ) ) ;
832826 }
833827 return {
834828 url : url ,
0 commit comments