mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-09-08 15:41:20 +02:00
refactor: Update form field identifiers and improve URL handling for NextCloud and WebDAV
- Changed input field IDs and names from 'dest_endpoint' and 'source_endpoint' to 'dest_host' and 'source_host' for consistency across NextCloud and WebDAV forms. - Updated placeholder texts for username, password, and file path fields to be more user-friendly. - Enhanced the URL parsing and validation logic in the transfer configuration generation to ensure proper handling of WebDAV and NextCloud URLs, improving robustness and error handling.
This commit is contained in:
@@ -10,12 +10,12 @@ templ NextCloudDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<label for="dest_endpoint" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">NextCloud URL</label>
|
<label for="dest_host" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">NextCloud URL</label>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
||||||
<i class="fas fa-cloud text-gray-400 dark:text-gray-500"></i>
|
<i class="fas fa-cloud text-gray-400 dark:text-gray-500"></i>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="dest_endpoint" name="dest_endpoint" x-model="destEndpoint" x-bind:required="requiresDestination"
|
<input type="text" id="dest_host" name="dest_host" x-model="destHost" x-bind:required="requiresDestination"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="https://nextcloud.example.com" />
|
placeholder="https://nextcloud.example.com" />
|
||||||
</div>
|
</div>
|
||||||
@@ -32,7 +32,7 @@ templ NextCloudDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" id="dest_user" name="dest_user" x-model="destUser" x-bind:required="requiresDestination"
|
<input type="text" id="dest_user" name="dest_user" x-model="destUser" x-bind:required="requiresDestination"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="nextcloud_username" />
|
placeholder="username" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your NextCloud username
|
Your NextCloud username
|
||||||
@@ -47,7 +47,7 @@ templ NextCloudDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="password" id="dest_password" name="dest_password" x-model="destPassword" x-bind:required="requiresDestination"
|
<input type="password" id="dest_password" name="dest_password" x-model="destPassword" x-bind:required="requiresDestination"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="NextCloud password" />
|
placeholder="password" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your NextCloud account password
|
Your NextCloud account password
|
||||||
@@ -62,10 +62,10 @@ templ NextCloudDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" id="destination_path" name="destination_path" x-model="destinationPath" x-bind:required="requiresDestination"
|
<input type="text" id="destination_path" name="destination_path" x-model="destinationPath" x-bind:required="requiresDestination"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="remote.php/dav/files/username/path/to/files" />
|
placeholder="/path/to/files" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Path to your files in NextCloud. Usually starts with "remote.php/dav/files/username/"
|
Path to your files in NextCloud
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ templ WebDAVDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<label for="dest_endpoint" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">WebDAV URL</label>
|
<label for="dest_host" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">WebDAV URL</label>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
||||||
<i class="fas fa-globe text-gray-400 dark:text-gray-500"></i>
|
<i class="fas fa-globe text-gray-400 dark:text-gray-500"></i>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="dest_endpoint" name="dest_endpoint" x-model="destEndpoint" x-bind:required="requiresDestination"
|
<input type="text" id="dest_host" name="dest_host" x-model="destHost" x-bind:required="requiresDestination"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="https://webdav.example.com" />
|
placeholder="https://webdav.example.com" />
|
||||||
</div>
|
</div>
|
||||||
@@ -32,7 +32,7 @@ templ WebDAVDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" id="dest_user" name="dest_user" x-model="destUser" x-bind:required="requiresDestination"
|
<input type="text" id="dest_user" name="dest_user" x-model="destUser" x-bind:required="requiresDestination"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="webdav_username" />
|
placeholder="username" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your WebDAV username
|
Your WebDAV username
|
||||||
@@ -47,7 +47,7 @@ templ WebDAVDestinationForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="password" id="dest_password" name="dest_password" x-model="destPassword" x-bind:required="requiresDestination"
|
<input type="password" id="dest_password" name="dest_password" x-model="destPassword" x-bind:required="requiresDestination"
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="WebDAV password" />
|
placeholder="password" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your WebDAV account password
|
Your WebDAV account password
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ templ NextCloudSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<label for="source_endpoint" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">NextCloud URL</label>
|
<label for="source_host" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">NextCloud URL</label>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
||||||
<i class="fas fa-cloud text-gray-400 dark:text-gray-500"></i>
|
<i class="fas fa-cloud text-gray-400 dark:text-gray-500"></i>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="source_endpoint" name="source_endpoint" x-model="sourceEndpoint" required
|
<input type="text" id="source_host" name="source_host" x-model="sourceHost" required
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="https://nextcloud.example.com" />
|
placeholder="https://nextcloud.example.com" />
|
||||||
</div>
|
</div>
|
||||||
@@ -32,7 +32,7 @@ templ NextCloudSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" id="source_user" name="source_user" x-model="sourceUser" required
|
<input type="text" id="source_user" name="source_user" x-model="sourceUser" required
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="nextcloud_username" />
|
placeholder="username" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your NextCloud username
|
Your NextCloud username
|
||||||
@@ -47,7 +47,7 @@ templ NextCloudSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="password" id="source_password" name="source_password" x-model="sourcePassword" required
|
<input type="password" id="source_password" name="source_password" x-model="sourcePassword" required
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="NextCloud password" />
|
placeholder="password" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your NextCloud account password
|
Your NextCloud account password
|
||||||
@@ -62,10 +62,10 @@ templ NextCloudSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" id="source_path" name="source_path" x-model="sourcePath" required
|
<input type="text" id="source_path" name="source_path" x-model="sourcePath" required
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="remote.php/dav/files/username/path/to/files" />
|
placeholder="/path/to/files" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Path to your files in NextCloud. Usually starts with "remote.php/dav/files/username/"
|
Path to your files in NextCloud
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ templ WebDAVSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<label for="source_endpoint" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">WebDAV URL</label>
|
<label for="source_host" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">WebDAV URL</label>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
||||||
<i class="fas fa-globe text-gray-400 dark:text-gray-500"></i>
|
<i class="fas fa-globe text-gray-400 dark:text-gray-500"></i>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="source_endpoint" name="source_endpoint" x-model="sourceEndpoint" required
|
<input type="text" id="source_host" name="source_host" x-model="sourceHost" required
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="https://webdav.example.com" />
|
placeholder="https://webdav.example.com" />
|
||||||
</div>
|
</div>
|
||||||
@@ -32,7 +32,7 @@ templ WebDAVSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" id="source_user" name="source_user" x-model="sourceUser" required
|
<input type="text" id="source_user" name="source_user" x-model="sourceUser" required
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="webdav_username" />
|
placeholder="username" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your WebDAV username
|
Your WebDAV username
|
||||||
@@ -47,7 +47,7 @@ templ WebDAVSourceForm() {
|
|||||||
</div>
|
</div>
|
||||||
<input type="password" id="source_password" name="source_password" x-model="sourcePassword" required
|
<input type="password" id="source_password" name="source_password" x-model="sourcePassword" required
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
placeholder="WebDAV password" />
|
placeholder="password" />
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
|
||||||
Your WebDAV account password
|
Your WebDAV account password
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -149,7 +150,49 @@ func (db *DB) GenerateRcloneConfig(config *TransferConfig) error {
|
|||||||
if output, err := cmd.CombinedOutput(); err != nil {
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("failed to create source config (minio): %v\nOutput: %s", err, output)
|
return fmt.Errorf("failed to create source config (minio): %v\nOutput: %s", err, output)
|
||||||
}
|
}
|
||||||
// ... (Add cases for other source types: b2, smb, ftp, webdav, nextcloud, onedrive, gdrive, gphotos) ...
|
case "webdav", "nextcloud": // Handle both webdav and nextcloud similarly
|
||||||
|
// Construct the WebDAV URL
|
||||||
|
// Parse the provided source URL, assuming it includes the scheme
|
||||||
|
inputURL := config.SourceHost
|
||||||
|
parsedURL, err := url.Parse(inputURL)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to parse source URL '%s': %v", inputURL, err)
|
||||||
|
}
|
||||||
|
// Validate that both scheme and host are present
|
||||||
|
if parsedURL.Scheme == "" || parsedURL.Host == "" {
|
||||||
|
return fmt.Errorf("invalid source URL '%s': must include scheme (http/https) and host", inputURL)
|
||||||
|
}
|
||||||
|
// Use the scheme and host from the parsed URL
|
||||||
|
webdavURL := fmt.Sprintf("%s://%s", parsedURL.Scheme, parsedURL.Host)
|
||||||
|
|
||||||
|
// Determine vendor based on type
|
||||||
|
vendor := "other" // Default vendor
|
||||||
|
if config.SourceType == "nextcloud" {
|
||||||
|
vendor = "nextcloud"
|
||||||
|
|
||||||
|
// Construct the full Nextcloud path using the parsed base URL
|
||||||
|
webdavURL = fmt.Sprintf("%s/remote.php/dav/files/%s/", webdavURL, config.SourceUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []string{
|
||||||
|
"config", "create", sourceName, "webdav",
|
||||||
|
"url", webdavURL,
|
||||||
|
"vendor", vendor,
|
||||||
|
"user", config.SourceUser,
|
||||||
|
"pass", config.SourcePassword, // rclone obscures this
|
||||||
|
"--non-interactive",
|
||||||
|
"--config", configPath,
|
||||||
|
"--log-level", "ERROR",
|
||||||
|
}
|
||||||
|
cmd := exec.Command(rclonePath, args...)
|
||||||
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
|
errorMsg := fmt.Sprintf("failed to create source config (%s): %v", config.SourceType, err)
|
||||||
|
// Check if output contains useful info, especially for auth errors
|
||||||
|
if len(output) > 0 {
|
||||||
|
errorMsg += fmt.Sprintf("\nOutput: %s", output)
|
||||||
|
}
|
||||||
|
return fmt.Errorf(errorMsg)
|
||||||
|
}
|
||||||
case "local":
|
case "local":
|
||||||
// For local source, ensure the section exists but might not need specific rclone config create
|
// For local source, ensure the section exists but might not need specific rclone config create
|
||||||
content := fmt.Sprintf("[%s]\ntype = local\n\n", sourceName)
|
content := fmt.Sprintf("[%s]\ntype = local\n\n", sourceName)
|
||||||
@@ -224,7 +267,47 @@ func (db *DB) GenerateRcloneConfig(config *TransferConfig) error {
|
|||||||
if output, err := cmd.CombinedOutput(); err != nil {
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("failed to create destination config (minio): %v\nOutput: %s", err, output)
|
return fmt.Errorf("failed to create destination config (minio): %v\nOutput: %s", err, output)
|
||||||
}
|
}
|
||||||
// ... (Add cases for other destination types: b2, smb, ftp, webdav, nextcloud, onedrive, gdrive, gphotos) ...
|
case "webdav", "nextcloud": // Combined case for WebDAV and Nextcloud
|
||||||
|
// Parse and reconstruct the WebDAV URL robustly
|
||||||
|
// Parse the provided destination URL, assuming it includes the scheme
|
||||||
|
inputURL := config.DestHost
|
||||||
|
parsedURL, err := url.Parse(inputURL)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to parse destination URL '%s': %v", inputURL, err)
|
||||||
|
}
|
||||||
|
// Validate that both scheme and host are present
|
||||||
|
if parsedURL.Scheme == "" || parsedURL.Host == "" {
|
||||||
|
return fmt.Errorf("invalid destination URL '%s': must include scheme (http/https) and host", inputURL)
|
||||||
|
}
|
||||||
|
// Use the scheme and host from the parsed URL
|
||||||
|
webdavURL := fmt.Sprintf("%s://%s", parsedURL.Scheme, parsedURL.Host)
|
||||||
|
|
||||||
|
// Determine vendor based on type
|
||||||
|
vendor := "other" // Default vendor
|
||||||
|
if config.DestinationType == "nextcloud" {
|
||||||
|
vendor = "nextcloud"
|
||||||
|
|
||||||
|
webdavURL = fmt.Sprintf("%s/remote.php/dav/files/%s/", webdavURL, config.DestUser) // Corrected variable
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []string{
|
||||||
|
"config", "create", destName, "webdav",
|
||||||
|
"url", webdavURL, // Use the parsed and reconstructed URL
|
||||||
|
"vendor", vendor,
|
||||||
|
"user", config.DestUser,
|
||||||
|
"pass", config.DestPassword, // rclone obscures this
|
||||||
|
"--non-interactive",
|
||||||
|
"--config", configPath,
|
||||||
|
"--log-level", "ERROR",
|
||||||
|
}
|
||||||
|
cmd := exec.Command(rclonePath, args...)
|
||||||
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
|
errorMsg := fmt.Sprintf("failed to create destination config (%s): %v", config.DestinationType, err)
|
||||||
|
if len(output) > 0 {
|
||||||
|
errorMsg += fmt.Sprintf("\nOutput: %s", output)
|
||||||
|
}
|
||||||
|
return fmt.Errorf(errorMsg)
|
||||||
|
}
|
||||||
case "local":
|
case "local":
|
||||||
// Append local config section
|
// Append local config section
|
||||||
content := fmt.Sprintf("\n[%s]\ntype = local\n", destName)
|
content := fmt.Sprintf("\n[%s]\ntype = local\n", destName)
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ func (h *Handlers) HandleCreateConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate rclone config file
|
// Generate rclone config file
|
||||||
|
|
||||||
if err := h.DB.GenerateRcloneConfig(&config); err != nil {
|
if err := h.DB.GenerateRcloneConfig(&config); err != nil {
|
||||||
log.Printf("Warning: Failed to generate rclone config: %v", err)
|
log.Printf("Warning: Failed to generate rclone config: %v", err)
|
||||||
// Continue anyway, as the config was created in the database
|
// Continue anyway, as the config was created in the database
|
||||||
|
|||||||
Reference in New Issue
Block a user