Improve output of publish-to-ipfs.ps1

This commit is contained in:
Markus Fleschutz 2021-09-01 09:23:25 +02:00
parent b6a5cccbe2
commit e6577ade65

View File

@ -18,25 +18,29 @@ try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
""
"Step 1/3: Searching for IPFS executable..."
& ipfs --version & ipfs --version
if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" } 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) {
"Publishing folder $Files/ to IPFS..." ""
"Step 2/3: Publishing folder $Files/ to IPFS..."
[int]$Count = 1 [int]$Count = 1
& ipfs add -r "$Files" > $HashList & ipfs add -r "$Files" > $HashList
echo "Calculating digital forensics hashes to $DF_HASHES ..." ""
echo "Step 3/3: Calculating digital forensics hashes to $DF_HASHES ..."
& nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$Files" > $DF_Hashes & nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$Files" > $DF_Hashes
} else { } else {
$FileList = (get-childItem "$Files") $FileList = (get-childItem "$Files")
[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) {
"Publishing folder $File/ to IPFS..." "Step 2/3: Publishing folder $File/ to IPFS..."
& ipfs add -r "$File" >> $HashList & ipfs add -r "$File" >> $HashList
} else { } else {
"Publishing file $File to IPFS..." "Step 2/3: Publishing file $File to IPFS..."
& ipfs add "$File" >> $HashList & ipfs add "$File" >> $HashList
} }
} }