mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: clean up cloud storage components
This commit is contained in:
@@ -210,7 +210,8 @@ export const ShowCloudBackups = ({ databaseId, databaseType }: Props) => {
|
||||
setActiveManualBackup(undefined);
|
||||
}}
|
||||
>
|
||||
{isManualBackup && activeManualBackup === backup.id ? (
|
||||
{isManualBackup &&
|
||||
activeManualBackup === backup.id ? (
|
||||
<div className="animate-spin rounded-full h-5 w-5 border-b-2 border-primary" />
|
||||
) : (
|
||||
<Play className="size-5 text-muted-foreground" />
|
||||
|
||||
@@ -249,7 +249,7 @@ export const CloudStorageDestinations = ({
|
||||
if (!result.token) {
|
||||
toast.success("Connection test successful");
|
||||
}
|
||||
} catch (err: any) {
|
||||
} catch (_err: any) {
|
||||
setConnectionTested(false);
|
||||
form.setValue("token", "");
|
||||
toast.error("Connection test failed", {
|
||||
|
||||
@@ -100,6 +100,16 @@ async function withSilentTokenRefresh(params: {
|
||||
) {
|
||||
console.log("Token expired or invalid, attempting refresh");
|
||||
credentials.token = undefined;
|
||||
// Update the config in database to reflect token removal
|
||||
if (updateConfig) {
|
||||
await db
|
||||
.update(cloudStorageDestination)
|
||||
.set({
|
||||
config: JSON.stringify(credentials),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(cloudStorageDestination.id, destination.id));
|
||||
}
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
@@ -222,9 +232,9 @@ export const cloudStorageBackupRouter = createTRPCRouter({
|
||||
console.log("Parsed files:", files);
|
||||
|
||||
const backupFiles = files
|
||||
.filter((file) =>
|
||||
file.Name.endsWith(".zip") ||
|
||||
file.Name.endsWith(".sql.gz")
|
||||
.filter(
|
||||
(file) =>
|
||||
file.Name.endsWith(".zip") || file.Name.endsWith(".sql.gz"),
|
||||
)
|
||||
.map((file) => ({
|
||||
path: file.Path,
|
||||
|
||||
@@ -277,7 +277,7 @@ export const executeCloudStorageRestore = async (
|
||||
const credentials = await getCloudStorageCredentials(destination);
|
||||
|
||||
// Get just the filename without any provider prefix
|
||||
const cleanFileName = fileName.replace(/^[^:]+:/, '');
|
||||
const cleanFileName = fileName.replace(/^[^:]+:/, "");
|
||||
|
||||
// Construct the full path for the cloud storage provider
|
||||
const normalizedPrefix = normalizeCloudPath(backup.prefix || "");
|
||||
@@ -387,7 +387,7 @@ export const executeCloudStorageRestore = async (
|
||||
}
|
||||
|
||||
if (restoreCommand) {
|
||||
emit(`Executing restore command...`);
|
||||
emit("Executing restore command...");
|
||||
await execAsync(restoreCommand);
|
||||
}
|
||||
|
||||
@@ -499,4 +499,3 @@ export const keepLatestNCloudStorageBackups = async (
|
||||
console.error("Error keeping latest backups:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user