This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify dryRun/listOnly logic, move into receive
- Loading branch information
1 parent
c4cc8c4
commit 567e6b2
Showing
5 changed files
with
41 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import Dat from './lib/dat' | ||
import DatCp from './lib/dat-cp' | ||
|
||
export default async function receive(key, program) { | ||
export default async function receive(key, options) { | ||
const dat = await Dat({key, sparse: true}) | ||
|
||
const datCp = new DatCp(dat, program) | ||
if (!options.skipPrompt) { | ||
const datCpDryRun = new DatCp(dat, {...options, dryRun: true}) | ||
|
||
if (!program.skipPrompt) { | ||
await datCp.download(true) | ||
} | ||
await datCpDryRun.download() | ||
|
||
if (program.dryRun || (!program.skipPrompt && datCp.files === 0)) { | ||
process.exit() | ||
} | ||
if (options.dryRun || datCpDryRun.files === 0) { | ||
datCpDryRun.printTotal() | ||
process.exit() | ||
} | ||
|
||
if (!program.skipPrompt) { | ||
const proceed = await datCp.downloadPrompt() | ||
const proceed = await datCpDryRun.downloadPrompt() | ||
|
||
if (!proceed) { | ||
process.exit() | ||
} | ||
} | ||
|
||
datCp.resetCounts() | ||
await datCp.download() | ||
const datCpDownload = new DatCp(dat, {...options}) | ||
|
||
await datCpDownload.download() | ||
|
||
if (options.skipPrompt || datCpDownload.files > 30) { | ||
datCpDownload.printTotal() | ||
} | ||
|
||
process.exit() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters