mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-29 05:09:05 +02:00
Improve publish-to-ipfs.ps1
This commit is contained in:
parent
efe8a7db6e
commit
16c1026a4c
@ -2,7 +2,7 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
publish-to-ipfs.ps1 [<file(s)/dir>] [<to-hash-list>]
|
publish-to-ipfs.ps1 [<file(s)/dir>] [<to-hash-list>]
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Publishes the given files and folders to IPFS
|
Publishes the given files & folders to IPFS
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> .\publish-to-ipfs.ps1 C:\MyFile.txt
|
PS> .\publish-to-ipfs.ps1 C:\MyFile.txt
|
||||||
.LINK
|
.LINK
|
||||||
@ -15,14 +15,15 @@
|
|||||||
param([string]$Files = "", [string]$HashList = "IPFS_hashes.txt", [string]$DF_Hashes = "file_checksums.xml")
|
param([string]$Files = "", [string]$HashList = "IPFS_hashes.txt", [string]$DF_Hashes = "file_checksums.xml")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
& ipfs --version
|
|
||||||
if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" }
|
|
||||||
|
|
||||||
if ($Files -eq "") { $Files = read-host "Enter file(s) or directory tree to publish" }
|
if ($Files -eq "") { $Files = read-host "Enter file(s) or directory tree to publish" }
|
||||||
|
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
|
& ipfs --version
|
||||||
|
if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" }
|
||||||
|
|
||||||
if (test-path "$Files" -pathType container) {
|
if (test-path "$Files" -pathType container) {
|
||||||
"Adding folder $Files to IPFS..."
|
"Publishing folder $Files/ to IPFS..."
|
||||||
[int]$Count = 1
|
[int]$Count = 1
|
||||||
& ipfs add -r "$Files" > $HashList
|
& ipfs add -r "$Files" > $HashList
|
||||||
|
|
||||||
@ -33,10 +34,10 @@ try {
|
|||||||
[int]$Count = $FileList.Count
|
[int]$Count = $FileList.Count
|
||||||
foreach ($File in $FileList) {
|
foreach ($File in $FileList) {
|
||||||
if (test-path "$Files" -pathType container) {
|
if (test-path "$Files" -pathType container) {
|
||||||
"Adding folder $File to IPFS..."
|
"Publishing folder $File/ to IPFS..."
|
||||||
& ipfs add -r "$File" >> $HashList
|
& ipfs add -r "$File" >> $HashList
|
||||||
} else {
|
} else {
|
||||||
"Adding file $File to IPFS..."
|
"Publishing file $File to IPFS..."
|
||||||
& ipfs add "$File" >> $HashList
|
& ipfs add "$File" >> $HashList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user