@@ -2,14 +2,14 @@ const fs = require('fs').promises
22const p = require ( 'path' )
33
44const cliProgress = require ( 'cli-progress' )
5- const mirrorFolder = require ( 'mirror-folder' )
65const { flags } = require ( '@oclif/command' )
76
87const DaemonCommand = require ( '../../lib/cli' )
9- const { HyperdriveClient } = require ( '../..' )
108
11- const IMPORT_KEY_FILE_PATH = '.hyperdrive-import-key'
12- const EXPORT_KEY_FILE_PATH = '.hyperdrive-export-key'
9+ const {
10+ importKeyFilePath : IMPORT_KEY_FILE_PATH ,
11+ exportKeyFilePath : EXPORT_KEY_FILE_PATH
12+ } = require ( '../../lib/constants' )
1313
1414class ImportCommand extends DaemonCommand {
1515 static usage = 'import [dir] [key]'
@@ -64,16 +64,8 @@ class ImportCommand extends DaemonCommand {
6464 console . log ( `Importing ${ args . dir } into ${ drive . key . toString ( 'hex' ) } (Ctrl+c to exit)...` )
6565 console . log ( )
6666
67- const localMirror = mirrorFolder ( args . dir , { fs : drive , name : '/' } , {
68- watch : true ,
69- dereference : true ,
70- // When going from fs -> drive, it should overwrite.
71- keepExisting : false ,
72- ignore : ( file , stat , cb ) => {
73- if ( shouldIgnore ( file ) ) return process . nextTick ( cb , null , true )
74- return process . nextTick ( cb , null , false )
75- }
76- } )
67+ const localMirror = this . client . drive . import ( args . dir , drive )
68+
7769 localMirror . on ( 'pending' , ( { name } ) => {
7870 if ( shouldIgnore ( name ) ) return
7971 progress . setTotal ( ++ total )
@@ -116,12 +108,7 @@ class ImportCommand extends DaemonCommand {
116108 return fs . writeFile ( keyPath , drive . key )
117109 }
118110
119- function shouldIgnore ( name ) {
120- if ( ! name ) return true
121- if ( name . indexOf ( EXPORT_KEY_FILE_PATH ) !== - 1 ) return true
122- else if ( name . indexOf ( IMPORT_KEY_FILE_PATH ) !== - 1 ) return true
123- return false
124- }
111+
125112 }
126113}
127114
0 commit comments