mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(backups): implement normalizeS3Path utility and integrate into backup processes
- Added normalizeS3Path function to standardize S3 path formatting by trimming whitespace and removing leading/trailing slashes. - Updated backup-related modules (MySQL, MongoDB, PostgreSQL, MariaDB, and web server) to utilize normalizeS3Path for consistent S3 path handling. - Introduced unit tests for normalizeS3Path to ensure correct functionality across various input scenarios.
This commit is contained in:
@@ -31,7 +31,10 @@ import {
|
||||
} from "@dokploy/server";
|
||||
|
||||
import { findDestinationById } from "@dokploy/server/services/destination";
|
||||
import { getS3Credentials } from "@dokploy/server/utils/backups/utils";
|
||||
import {
|
||||
getS3Credentials,
|
||||
normalizeS3Path,
|
||||
} from "@dokploy/server/utils/backups/utils";
|
||||
import {
|
||||
execAsync,
|
||||
execAsyncRemote,
|
||||
@@ -257,7 +260,7 @@ export const backupRouter = createTRPCRouter({
|
||||
const lastSlashIndex = input.search.lastIndexOf("/");
|
||||
const baseDir =
|
||||
lastSlashIndex !== -1
|
||||
? input.search.slice(0, lastSlashIndex + 1)
|
||||
? normalizeS3Path(input.search.slice(0, lastSlashIndex + 1))
|
||||
: "";
|
||||
const searchTerm =
|
||||
lastSlashIndex !== -1
|
||||
@@ -270,7 +273,7 @@ export const backupRouter = createTRPCRouter({
|
||||
let stdout = "";
|
||||
|
||||
if (input.serverId) {
|
||||
const result = await execAsyncRemote(listCommand, input.serverId);
|
||||
const result = await execAsyncRemote(input.serverId, listCommand);
|
||||
stdout = result.stdout;
|
||||
} else {
|
||||
const result = await execAsync(listCommand);
|
||||
|
||||
Reference in New Issue
Block a user