mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
feat: Working on UI/UX for multiple storage backends.
This commit is contained in:
@@ -32,6 +32,7 @@ import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/compon
|
||||
import {MemberWithUser} from "@/db/schema/03_organization";
|
||||
import {formatLocalizedDate} from "@/utils/date-formatting";
|
||||
import {formatBytes, isImportedFilename} from "@/utils/text";
|
||||
import {DatabaseActionsCell} from "@/components/wrappers/dashboard/database/backup/actions/backup-actions-cell";
|
||||
|
||||
|
||||
export function backupColumns(
|
||||
@@ -92,6 +93,10 @@ export function backupColumns(
|
||||
return <StatusBadge status={row.getValue("status")}/>;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "actions2",
|
||||
cell: ({row}) => <DatabaseActionsCell activeMember={activeMember} backup={row.original}/>,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
cell: ({row, table}) => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Backup, DatabaseWith } from "@/db/schema/07_database";
|
||||
import { dispatchStorage } from "@/features/storages/dispatch";
|
||||
import type { StorageInput, StorageResult } from "@/features/storages/types";
|
||||
import {Backup, DatabaseWith} from "@/db/schema/07_database";
|
||||
import {dispatchStorage} from "@/features/storages/dispatch";
|
||||
import type {StorageInput, StorageResult} from "@/features/storages/types";
|
||||
import * as drizzleDb from "@/db";
|
||||
import { withUpdatedAt } from "@/db/utils";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "@/db";
|
||||
import { createHash } from "crypto";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {db} from "@/db";
|
||||
import {createHash} from "crypto";
|
||||
|
||||
function computeChecksum(buffer: Buffer): string {
|
||||
return createHash("sha256").update(buffer).digest("hex");
|
||||
@@ -20,7 +20,7 @@ export async function storeBackupFiles(
|
||||
|
||||
const settings = await db.query.setting.findFirst({
|
||||
where: eq(drizzleDb.schemas.setting.name, "system"),
|
||||
with: { storageChannel: true },
|
||||
with: {storageChannel: true},
|
||||
});
|
||||
|
||||
const defaultPolicy = settings?.storageChannel
|
||||
@@ -62,16 +62,16 @@ export async function storeBackupFiles(
|
||||
|
||||
const input: StorageInput = {
|
||||
action: "upload",
|
||||
data: { path, file },
|
||||
data: {path, file},
|
||||
};
|
||||
|
||||
// const result = await dispatchStorage(input, policy.id);
|
||||
let result: StorageResult;
|
||||
|
||||
try {
|
||||
if (policy.id){
|
||||
if (policy.id) {
|
||||
result = await dispatchStorage(input, policy.id);
|
||||
}else{
|
||||
} else {
|
||||
result = await dispatchStorage(input, undefined, policy.storageChannelId);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export async function storeBackupFiles(
|
||||
|
||||
await db
|
||||
.update(drizzleDb.schemas.backupStorage)
|
||||
.set(withUpdatedAt({ status: result.success ? "success" : "failed" }))
|
||||
.set(withUpdatedAt({status: result.success ? "success" : "failed"}))
|
||||
.where(eq(drizzleDb.schemas.backupStorage.id, backupStorage.id));
|
||||
|
||||
return result;
|
||||
@@ -99,7 +99,10 @@ export async function storeBackupFiles(
|
||||
|
||||
await db
|
||||
.update(drizzleDb.schemas.backup)
|
||||
.set(withUpdatedAt({ status: backupStatus }))
|
||||
.set(withUpdatedAt({
|
||||
status: backupStatus,
|
||||
fileSize: size
|
||||
}))
|
||||
.where(eq(drizzleDb.schemas.backup.id, backup.id));
|
||||
|
||||
return results;
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function uploadLocal(
|
||||
|
||||
const dir = path.dirname(fullPath);
|
||||
|
||||
await mkdir(dir, { recursive: true });
|
||||
await mkdir(dir, {recursive: true});
|
||||
await writeFile(fullPath, input.data.file);
|
||||
|
||||
return {
|
||||
@@ -31,14 +31,14 @@ export async function getLocal(
|
||||
input: { data: StorageGetInput }
|
||||
): Promise<StorageResult> {
|
||||
const base = config.baseDir || BASE_DIR;
|
||||
const filePath = path.join(base, input.data.path)
|
||||
const filePath = path.join(process.cwd(), base, input.data.path)
|
||||
const fileName = path.basename(input.data.path);
|
||||
const file = await readFile(filePath);
|
||||
|
||||
const file = await readFile(filePath);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.error("File not found at:", filePath);
|
||||
return({
|
||||
return ({
|
||||
success: false,
|
||||
provider: 'local',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user