fix(synology): support vol_info in storage_v2 responses (#6554)
This commit is contained in:
3 files changed
+60
No files matched your search
@@ -85,6 +85,11 @@ export class SynologyClient {
|
|||||||
if (volumesFromV2.length > 0) {
|
if (volumesFromV2.length > 0) {
|
||||||
return volumesFromV2;
|
return volumesFromV2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const legacyVolumesFromV2 = this.mapLegacyVolumes(storageV2.vol_info);
|
||||||
|
if (legacyVolumesFromV2.length > 0) {
|
||||||
|
return legacyVolumesFromV2;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.debug("storage_v2 unavailable, falling back to legacy storage info", {
|
logger.debug("storage_v2 unavailable, falling back to legacy storage info", {
|
||||||
integrationId: this.integrationId,
|
integrationId: this.integrationId,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export const synologyStorageV2VolumeSchema = z
|
|||||||
|
|
||||||
export const synologyStorageV2DataSchema = z.object({
|
export const synologyStorageV2DataSchema = z.object({
|
||||||
volumes: z.array(synologyStorageV2VolumeSchema).optional(),
|
volumes: z.array(synologyStorageV2VolumeSchema).optional(),
|
||||||
|
vol_info: z.array(synologyVolumeInfoSchema).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const synologyUtilizationCpuSchema = z.object({
|
export const synologyUtilizationCpuSchema = z.object({
|
||||||
|
|||||||
@@ -426,6 +426,60 @@ describe("SynologyIntegration.getSystemInfoAsync", () => {
|
|||||||
expect(result.fileSystem[0]?.deviceName).toBe("volume_1");
|
expect(result.fileSystem[0]?.deviceName).toBe("volume_1");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("uses vol_info from storage_v2 without falling back to legacy storage", async () => {
|
||||||
|
mockSuccessfulFlow({
|
||||||
|
storageV2: {
|
||||||
|
success: true,
|
||||||
|
data: {
|
||||||
|
vol_info: [
|
||||||
|
{
|
||||||
|
name: "volume_1",
|
||||||
|
used_size: "4000000000",
|
||||||
|
total_size: "10000000000",
|
||||||
|
status: "normal",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "volume_2",
|
||||||
|
used_size: "5000000000",
|
||||||
|
total_size: "20000000000",
|
||||||
|
status: "attention",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const integration = createIntegration();
|
||||||
|
const result = await integration.getSystemInfoAsync();
|
||||||
|
|
||||||
|
expect(result.fileSystem).toEqual([
|
||||||
|
{
|
||||||
|
deviceName: "volume_1",
|
||||||
|
used: "4000000000",
|
||||||
|
available: "6000000000",
|
||||||
|
percentage: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deviceName: "volume_2",
|
||||||
|
used: "5000000000",
|
||||||
|
available: "15000000000",
|
||||||
|
percentage: 25,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const legacyStorageRequests = mockFetch.mock.calls.filter(([url]) => {
|
||||||
|
const urlString = toUrlString(url);
|
||||||
|
|
||||||
|
return (
|
||||||
|
getApiFromUrl(urlString) === "SYNO.Core.System" &&
|
||||||
|
getMethodFromUrl(urlString) === "info" &&
|
||||||
|
getTypeFromUrl(urlString) === "storage"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(legacyStorageRequests).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
test("continues when optional tier-2 calls fail", async () => {
|
test("continues when optional tier-2 calls fail", async () => {
|
||||||
mockSuccessfulFlow({ skipOptional: true });
|
mockSuccessfulFlow({ skipOptional: true });
|
||||||
const integration = createIntegration();
|
const integration = createIntegration();
|
||||||
|
|||||||
Reference in new issue
Block a user