mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-24 05:22:58 +00:00
Align host settings with the 1.0 lifecycle
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import type { SettingsMigrationState } from "@vrtmrz/livesync-commonlib/compat/common/types";
|
||||
import type {
|
||||
SettingsMigrationReviewReason,
|
||||
SettingsMigrationState,
|
||||
} from "@vrtmrz/livesync-commonlib/compat/common/types";
|
||||
|
||||
export const DATABASE_COMPATIBILITY_VERSION_KEY = "database-compatibility-version";
|
||||
export const DATABASE_COMPATIBILITY_LEGACY_VERSION_KEY_PREFIX = "obsidian-live-sync-ver";
|
||||
@@ -21,6 +24,7 @@ export interface SettingsCompatibilityReason {
|
||||
currentVersion: number;
|
||||
isFromFutureSchema: boolean;
|
||||
resumable: boolean;
|
||||
reviewReasons: readonly SettingsMigrationReviewReason[];
|
||||
}
|
||||
|
||||
export interface LegacyCompatibilityReason {
|
||||
@@ -51,6 +55,16 @@ export interface CompatibilityEvaluationInput {
|
||||
legacyReviewMessage: string;
|
||||
}
|
||||
|
||||
const FILENAME_CASE_SENSITIVITY_UNRESOLVED = "filename-case-sensitivity-unresolved";
|
||||
|
||||
export function requiresFilenameCaseSensitivityDecision(pause: CompatibilityPause): boolean {
|
||||
return pause.reasons.some(
|
||||
(reason) =>
|
||||
reason.source === "settings-schema" &&
|
||||
reason.reviewReasons.some(({ code }) => code === FILENAME_CASE_SENSITIVITY_UNRESOLVED)
|
||||
);
|
||||
}
|
||||
|
||||
function databaseVersionReason(
|
||||
acknowledgedVersion: string | null,
|
||||
currentVersion: number,
|
||||
@@ -112,6 +126,7 @@ export function evaluateCompatibilityPause(input: CompatibilityEvaluationInput):
|
||||
currentVersion: input.migrationState.targetVersion,
|
||||
isFromFutureSchema: input.migrationState.isFromFutureSchema,
|
||||
resumable: !input.migrationState.isFromFutureSchema,
|
||||
reviewReasons: input.migrationState.reviewReasons,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -103,11 +103,42 @@ describe("database compatibility evaluation", () => {
|
||||
currentVersion: 2,
|
||||
isFromFutureSchema: true,
|
||||
resumable: false,
|
||||
reviewReasons: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("retains an unresolved filename-case decision in the host compatibility reason", () => {
|
||||
const reviewReasons = [
|
||||
{
|
||||
code: "filename-case-sensitivity-unresolved",
|
||||
fromVersion: 10,
|
||||
toVersion: 10,
|
||||
},
|
||||
];
|
||||
const result = evaluateCompatibilityPause({
|
||||
acknowledgedVersion: "12",
|
||||
currentVersion: 12,
|
||||
migrationState: migrationState({
|
||||
sourceVersion: 10,
|
||||
targetVersion: 10,
|
||||
requiresSyncReview: true,
|
||||
reviewReasons,
|
||||
}),
|
||||
legacyReviewMessage: "",
|
||||
});
|
||||
|
||||
expect(result.pause?.reasons).toContainEqual({
|
||||
source: "settings-schema",
|
||||
sourceVersion: 10,
|
||||
currentVersion: 10,
|
||||
isFromFutureSchema: false,
|
||||
resumable: true,
|
||||
reviewReasons,
|
||||
});
|
||||
});
|
||||
|
||||
it("retains an existing legacy review when no structured reason can be reconstructed", () => {
|
||||
const result = evaluateCompatibilityPause({
|
||||
acknowledgedVersion: "12",
|
||||
|
||||
Reference in New Issue
Block a user