mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-23 13:02:58 +00:00
Preserve legacy settings across same-profile upgrades
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
CreateBucketCommand,
|
||||
DeleteObjectsCommand,
|
||||
GetObjectCommand,
|
||||
ListObjectsV2Command,
|
||||
S3Client,
|
||||
type _Object,
|
||||
@@ -120,6 +121,22 @@ export async function listObjectStorageObjects(config: ObjectStorageConfig, pref
|
||||
}
|
||||
}
|
||||
|
||||
export async function readObjectStorageObject(config: ObjectStorageConfig, key: string): Promise<Uint8Array> {
|
||||
const client = createObjectStorageClient(config);
|
||||
try {
|
||||
const response = await client.send(new GetObjectCommand({ Bucket: config.bucket, Key: key }));
|
||||
if (!response.Body) throw new Error(`Object Storage returned an empty body for ${key}.`);
|
||||
return await response.Body.transformToByteArray();
|
||||
} finally {
|
||||
client.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
export async function readObjectStorageJson<T>(config: ObjectStorageConfig, key: string): Promise<T> {
|
||||
const bytes = await readObjectStorageObject(config, key);
|
||||
return JSON.parse(new TextDecoder().decode(bytes)) as T;
|
||||
}
|
||||
|
||||
export async function deleteObjectStoragePrefix(config: ObjectStorageConfig, prefix: string): Promise<void> {
|
||||
const client = createObjectStorageClient(config);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user