restore
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mistifyio/go-zfs"
|
||||
@@ -121,7 +122,14 @@ func (c *Client) SendIncrementalHTTP(snapshot *zfs.Dataset, base string) error {
|
||||
}
|
||||
|
||||
reqBody, _ := json.Marshal(uploadReq)
|
||||
resp, err := http.Post(c.config.ServerURL+"/upload", "application/json", bytes.NewBuffer(reqBody))
|
||||
uploadURL := c.config.ServerURL
|
||||
// Ensure proper URL format
|
||||
if !strings.HasSuffix(uploadURL, "/") {
|
||||
uploadURL += "/"
|
||||
}
|
||||
uploadURL += "upload"
|
||||
|
||||
resp, err := http.Post(uploadURL, "application/json", bytes.NewBuffer(reqBody))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to request upload: %v", err)
|
||||
}
|
||||
@@ -193,7 +201,21 @@ func (c *Client) streamToServer(snapshot *zfs.Dataset, base, uploadURL, storageK
|
||||
}
|
||||
|
||||
// Create HTTP request to server
|
||||
req, err := http.NewRequest("POST", c.config.ServerURL+uploadURL, reader)
|
||||
// Build full URL properly
|
||||
fullURL := c.config.ServerURL
|
||||
// Remove trailing slash from base URL if present
|
||||
fullURL = strings.TrimRight(fullURL, "/")
|
||||
// Add leading slash to upload URL if not present
|
||||
if !strings.HasPrefix(uploadURL, "/") {
|
||||
uploadURL = "/" + uploadURL
|
||||
}
|
||||
fullURL += uploadURL
|
||||
|
||||
fmt.Printf(" Streaming to: %s\n", fullURL)
|
||||
|
||||
fmt.Printf("fullURL: %v\n", fullURL)
|
||||
|
||||
req, err := http.NewRequest("POST", fullURL, reader)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create request: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user