mirror of
https://github.com/fiatjaf/nak.git
synced 2026-09-13 22:25:06 +00:00
nsite: don't stop publish if only one of the blossom server uploads fail.
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -171,15 +172,20 @@ var nsite = &cli.Command{
|
||||
}
|
||||
|
||||
var hhash string
|
||||
var uploadErrors []error
|
||||
for _, server := range blossomServers {
|
||||
client := blossom.NewClient(server, kr)
|
||||
bd, err := client.UploadFilePath(ctx, path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to upload %s to %s: %w", path, server, err)
|
||||
uploadErrors = append(uploadErrors, fmt.Errorf("%s: %w", server, err))
|
||||
continue
|
||||
}
|
||||
hhash = bd.SHA256
|
||||
log("uploaded %s to %s as %s\n", color.GreenString(path), color.YellowString(server), color.CyanString(hhash))
|
||||
}
|
||||
if hhash == "" {
|
||||
return fmt.Errorf("failed to upload %s to any blossom server: %w", path, errors.Join(uploadErrors...))
|
||||
}
|
||||
|
||||
var hash [32]byte
|
||||
if _, err := hex.Decode(hash[:], []byte(hhash)); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user