conv
This commit is contained in:
@@ -51,7 +51,9 @@ export const Export: React.FC<ExportProps> = ({
|
||||
allCollectionsNameByID,
|
||||
}) => {
|
||||
const { showMiniDialog } = useBaseContext();
|
||||
const [exportStage, setExportStage] = useState(ExportStage.INIT);
|
||||
const [exportStage, setExportStage] = useState<ExportStage>(
|
||||
ExportStage.init,
|
||||
);
|
||||
const [exportFolder, setExportFolder] = useState("");
|
||||
const [continuousExport, setContinuousExport] = useState(false);
|
||||
const [exportProgress, setExportProgress] = useState<ExportProgress>({
|
||||
@@ -224,8 +226,8 @@ function ExportDirectory({ exportFolder, changeExportDirectory, exportStage }) {
|
||||
{exportFolder ? (
|
||||
<>
|
||||
<DirectoryPath path={exportFolder} />
|
||||
{exportStage === ExportStage.FINISHED ||
|
||||
exportStage === ExportStage.INIT ? (
|
||||
{exportStage === ExportStage.finished ||
|
||||
exportStage === ExportStage.init ? (
|
||||
<ChangeDirectoryOption
|
||||
onClick={changeExportDirectory}
|
||||
/>
|
||||
@@ -303,15 +305,15 @@ const ExportDynamicContent = ({
|
||||
allCollectionsNameByID: Map<number, string>;
|
||||
}) => {
|
||||
switch (exportStage) {
|
||||
case ExportStage.INIT:
|
||||
case ExportStage.init:
|
||||
return <ExportInit startExport={startExport} />;
|
||||
|
||||
case ExportStage.MIGRATION:
|
||||
case ExportStage.STARTING:
|
||||
case ExportStage.EXPORTING_FILES:
|
||||
case ExportStage.RENAMING_COLLECTION_FOLDERS:
|
||||
case ExportStage.TRASHING_DELETED_FILES:
|
||||
case ExportStage.TRASHING_DELETED_COLLECTIONS:
|
||||
case ExportStage.migration:
|
||||
case ExportStage.starting:
|
||||
case ExportStage.exportingFiles:
|
||||
case ExportStage.renamingCollectionFolders:
|
||||
case ExportStage.trashingDeletedFiles:
|
||||
case ExportStage.trashingDeletedCollections:
|
||||
return (
|
||||
<ExportInProgress
|
||||
exportStage={exportStage}
|
||||
@@ -320,7 +322,7 @@ const ExportDynamicContent = ({
|
||||
closeExportDialog={onHide}
|
||||
/>
|
||||
);
|
||||
case ExportStage.FINISHED:
|
||||
case ExportStage.finished:
|
||||
return (
|
||||
<ExportFinished
|
||||
onHide={onHide}
|
||||
|
||||
@@ -23,11 +23,11 @@ interface Props {
|
||||
export default function ExportInProgress(props: Props) {
|
||||
const showIndeterminateProgress = () => {
|
||||
return (
|
||||
props.exportStage === ExportStage.STARTING ||
|
||||
props.exportStage === ExportStage.MIGRATION ||
|
||||
props.exportStage === ExportStage.RENAMING_COLLECTION_FOLDERS ||
|
||||
props.exportStage === ExportStage.TRASHING_DELETED_FILES ||
|
||||
props.exportStage === ExportStage.TRASHING_DELETED_COLLECTIONS
|
||||
props.exportStage === ExportStage.starting ||
|
||||
props.exportStage === ExportStage.migration ||
|
||||
props.exportStage === ExportStage.renamingCollectionFolders ||
|
||||
props.exportStage === ExportStage.trashingDeletedFiles ||
|
||||
props.exportStage === ExportStage.trashingDeletedCollections
|
||||
);
|
||||
};
|
||||
return (
|
||||
@@ -35,18 +35,18 @@ export default function ExportInProgress(props: Props) {
|
||||
<DialogContent>
|
||||
<VerticallyCentered>
|
||||
<Typography sx={{ mb: 1.5 }}>
|
||||
{props.exportStage === ExportStage.STARTING ? (
|
||||
{props.exportStage === ExportStage.starting ? (
|
||||
t("export_starting")
|
||||
) : props.exportStage === ExportStage.MIGRATION ? (
|
||||
) : props.exportStage === ExportStage.migration ? (
|
||||
t("preparing")
|
||||
) : props.exportStage ===
|
||||
ExportStage.RENAMING_COLLECTION_FOLDERS ? (
|
||||
ExportStage.renamingCollectionFolders ? (
|
||||
t("renaming_album_folders")
|
||||
) : props.exportStage ===
|
||||
ExportStage.TRASHING_DELETED_FILES ? (
|
||||
ExportStage.trashingDeletedFiles ? (
|
||||
t("trashing_deleted_files")
|
||||
) : props.exportStage ===
|
||||
ExportStage.TRASHING_DELETED_COLLECTIONS ? (
|
||||
ExportStage.trashingDeletedCollections ? (
|
||||
t("trashing_deleted_albums")
|
||||
) : (
|
||||
<Typography
|
||||
|
||||
@@ -34,16 +34,18 @@ const exportRecordFileName = "export_status.json";
|
||||
*/
|
||||
const exportDirectoryName = "Ente Photos";
|
||||
|
||||
export enum ExportStage {
|
||||
INIT = 0,
|
||||
MIGRATION = 1,
|
||||
STARTING = 2,
|
||||
EXPORTING_FILES = 3,
|
||||
TRASHING_DELETED_FILES = 4,
|
||||
RENAMING_COLLECTION_FOLDERS = 5,
|
||||
TRASHING_DELETED_COLLECTIONS = 6,
|
||||
FINISHED = 7,
|
||||
}
|
||||
export const ExportStage = {
|
||||
init: 0,
|
||||
migration: 1,
|
||||
starting: 2,
|
||||
exportingFiles: 3,
|
||||
trashingDeletedFiles: 4,
|
||||
renamingCollectionFolders: 5,
|
||||
trashingDeletedCollections: 6,
|
||||
finished: 7,
|
||||
} as const;
|
||||
|
||||
export type ExportStage = (typeof ExportStage)[keyof typeof ExportStage];
|
||||
|
||||
export interface ExportProgress {
|
||||
success: number;
|
||||
@@ -63,7 +65,7 @@ export type FileExportNames = Record<string, string>;
|
||||
export const NULL_EXPORT_RECORD: ExportRecord = {
|
||||
version: 3,
|
||||
lastAttemptTimestamp: null,
|
||||
stage: ExportStage.INIT,
|
||||
stage: ExportStage.init,
|
||||
fileExportNames: {},
|
||||
collectionExportNames: {},
|
||||
};
|
||||
@@ -239,23 +241,23 @@ class ExportService {
|
||||
async preExport(exportFolder: string) {
|
||||
await this.verifyExportFolderExists(exportFolder);
|
||||
const exportRecord = await this.getExportRecord(exportFolder);
|
||||
await this.updateExportStage(ExportStage.MIGRATION);
|
||||
await this.updateExportStage(ExportStage.migration);
|
||||
await this.runMigration(
|
||||
exportFolder,
|
||||
exportRecord,
|
||||
this.updateExportProgress.bind(this),
|
||||
);
|
||||
await this.updateExportStage(ExportStage.STARTING);
|
||||
await this.updateExportStage(ExportStage.starting);
|
||||
}
|
||||
|
||||
async postExport() {
|
||||
try {
|
||||
const exportFolder = this.getExportSettings()?.folder;
|
||||
if (!(await this.exportFolderExists(exportFolder))) {
|
||||
this.uiUpdater.setExportStage(ExportStage.INIT);
|
||||
this.uiUpdater.setExportStage(ExportStage.init);
|
||||
return;
|
||||
}
|
||||
await this.updateExportStage(ExportStage.FINISHED);
|
||||
await this.updateExportStage(ExportStage.finished);
|
||||
await this.updateLastExportTime(Date.now());
|
||||
|
||||
const exportRecord = await this.getExportRecord(exportFolder);
|
||||
@@ -401,7 +403,7 @@ class ExportService {
|
||||
});
|
||||
};
|
||||
if (renamedCollections?.length > 0) {
|
||||
this.updateExportStage(ExportStage.RENAMING_COLLECTION_FOLDERS);
|
||||
this.updateExportStage(ExportStage.renamingCollectionFolders);
|
||||
log.info(`renaming ${renamedCollections.length} collections`);
|
||||
await this.collectionRenamer(
|
||||
exportFolder,
|
||||
@@ -412,7 +414,7 @@ class ExportService {
|
||||
}
|
||||
|
||||
if (removedFileUIDs?.length > 0) {
|
||||
this.updateExportStage(ExportStage.TRASHING_DELETED_FILES);
|
||||
this.updateExportStage(ExportStage.trashingDeletedFiles);
|
||||
log.info(`trashing ${removedFileUIDs.length} files`);
|
||||
await this.fileTrasher(
|
||||
exportFolder,
|
||||
@@ -422,7 +424,7 @@ class ExportService {
|
||||
);
|
||||
}
|
||||
if (filesToExport?.length > 0) {
|
||||
this.updateExportStage(ExportStage.EXPORTING_FILES);
|
||||
this.updateExportStage(ExportStage.exportingFiles);
|
||||
log.info(`exporting ${filesToExport.length} files`);
|
||||
await this.fileExporter(
|
||||
filesToExport,
|
||||
@@ -435,9 +437,7 @@ class ExportService {
|
||||
);
|
||||
}
|
||||
if (deletedExportedCollections?.length > 0) {
|
||||
this.updateExportStage(
|
||||
ExportStage.TRASHING_DELETED_COLLECTIONS,
|
||||
);
|
||||
this.updateExportStage(ExportStage.trashingDeletedCollections);
|
||||
log.info(
|
||||
`removing ${deletedExportedCollections.length} collections`,
|
||||
);
|
||||
@@ -1449,7 +1449,7 @@ const parseLivePhotoExportName = (
|
||||
};
|
||||
|
||||
const isExportInProgress = (exportStage: ExportStage) =>
|
||||
exportStage > ExportStage.INIT && exportStage < ExportStage.FINISHED;
|
||||
exportStage > ExportStage.init && exportStage < ExportStage.finished;
|
||||
|
||||
/**
|
||||
* Move {@link fileName} in {@link collectionName} to the special per-collection
|
||||
|
||||
Reference in New Issue
Block a user