fix types

This commit is contained in:
Abhinav 2023-05-04 19:06:54 +05:30
parent c21462214d
commit d6f993210a
3 changed files with 19 additions and 18 deletions

View file

@ -75,7 +75,7 @@ async function migrateExport(
addLogLine(`current export version: ${exportRecord.version}`);
if (exportRecord.version === 0) {
addLogLine('migrating export to version 1');
await migrationV0ToV1(exportDir, exportRecord);
await migrationV0ToV1(exportDir, exportRecord as ExportRecordV0);
exportRecord = await exportService.updateExportRecord({
version: 1,
});
@ -83,7 +83,7 @@ async function migrateExport(
}
if (exportRecord.version === 1) {
addLogLine('migrating export to version 2');
await migrationV1ToV2(exportRecord);
await migrationV1ToV2(exportRecord as ExportRecordV1);
exportRecord = await exportService.updateExportRecord({
version: 2,
});
@ -357,7 +357,7 @@ async function addCollectionExportedRecordV1(
try {
const exportRecord = (await exportService.getExportRecord(
folder
)) as ExportRecordV1;
)) as unknown as ExportRecordV1;
if (!exportRecord?.exportedCollectionPaths) {
exportRecord.exportedCollectionPaths = {};
}

View file

@ -23,23 +23,23 @@ export interface FileExportStats {
}
export interface ExportRecordV0 {
stage?: ExportStage;
lastAttemptTimestamp?: number;
progress?: ExportProgress;
queuedFiles?: string[];
exportedFiles?: string[];
failedFiles?: string[];
stage: ExportStage;
lastAttemptTimestamp: number;
progress: ExportProgress;
queuedFiles: string[];
exportedFiles: string[];
failedFiles: string[];
}
export interface ExportRecordV1 {
version?: number;
stage?: ExportStage;
lastAttemptTimestamp?: number;
progress?: ExportProgress;
queuedFiles?: string[];
exportedFiles?: string[];
failedFiles?: string[];
exportedCollectionPaths?: ExportedCollectionPaths;
version: number;
stage: ExportStage;
lastAttemptTimestamp: number;
progress: ExportProgress;
queuedFiles: string[];
exportedFiles: string[];
failedFiles: string[];
exportedCollectionPaths: ExportedCollectionPaths;
}
export interface ExportRecordV2 {

View file

@ -1,6 +1,7 @@
import { ENTE_METADATA_FOLDER } from 'constants/export';
import {
ExportedCollectionPaths,
ExportRecordV0,
ExportRecordV1,
ExportRecordV2,
} from 'types/export';
@ -21,7 +22,7 @@ export const convertCollectionIDFolderPathObjectToMap = (
export const getExportedFiles = (
allFiles: EnteFile[],
exportRecord: ExportRecordV1 | ExportRecordV2
exportRecord: ExportRecordV0 | ExportRecordV1 | ExportRecordV2
) => {
if (!exportRecord?.exportedFiles) {
return [];