Fix page bucket: GetBucketInfo de Garage 2.x n'a pas localAliases, reponse normalisee (getBucket)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f01dad73ef
commit
8de5262c12
5 files changed
+38
-12
No files matched your search
+28
-2
@@ -173,7 +173,33 @@ export const appApi = {
|
||||
cli: (args: string[]) => req<{ exitCode: number; output: string; ms: number }>("/api/cli", { method: "POST", body: JSON.stringify({ args }) }),
|
||||
};
|
||||
|
||||
export const bucketName = (b: { id: string; globalAliases: string[]; localAliases: { alias: string }[] }) =>
|
||||
b.globalAliases[0] ?? b.localAliases[0]?.alias ?? b.id.slice(0, 12);
|
||||
export const bucketName = (b: { id: string; globalAliases?: string[]; localAliases?: { alias: string }[] }) =>
|
||||
b.globalAliases?.[0] ?? b.localAliases?.[0]?.alias ?? b.id.slice(0, 12);
|
||||
|
||||
/**
|
||||
* GetBucketInfo, normalisé : Garage 2.x ne renvoie pas `localAliases` au niveau du bucket (ils sont
|
||||
* dans `keys[].bucketLocalAliases`) et peut omettre d'autres champs ; l'interface n'a ainsi jamais
|
||||
* à tester leur présence.
|
||||
*/
|
||||
export async function getBucket(id: string): Promise<BucketInfo> {
|
||||
const b = await garage.get<Partial<BucketInfo>>("GetBucketInfo", { id });
|
||||
const keys = b.keys ?? [];
|
||||
return {
|
||||
id: b.id ?? id,
|
||||
created: b.created ?? "",
|
||||
globalAliases: b.globalAliases ?? [],
|
||||
localAliases: b.localAliases ?? keys.flatMap((k) => (k.bucketLocalAliases ?? []).map((alias) => ({ accessKeyId: k.accessKeyId, alias }))),
|
||||
websiteAccess: !!b.websiteAccess,
|
||||
websiteConfig: b.websiteConfig ?? null,
|
||||
keys,
|
||||
objects: b.objects ?? 0,
|
||||
bytes: b.bytes ?? 0,
|
||||
unfinishedUploads: b.unfinishedUploads ?? 0,
|
||||
unfinishedMultipartUploads: b.unfinishedMultipartUploads ?? 0,
|
||||
unfinishedMultipartUploadParts: b.unfinishedMultipartUploadParts ?? 0,
|
||||
unfinishedMultipartUploadBytes: b.unfinishedMultipartUploadBytes ?? 0,
|
||||
quotas: b.quotas ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
export const errMsg = (e: unknown) => (e instanceof Error ? e.message : String(e));
|
||||
Reference in new issue
Block a user