Merge pull request #202 from ente-io/update-migrate-thumbnail-copies

add new NOOP state to migrateThumbnail
This commit is contained in:
Abhinav-grd 2021-10-30 18:50:29 +05:30 committed by GitHub
commit 87cfff1a52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -24,6 +24,7 @@ interface Props {
export enum FIX_STATE { export enum FIX_STATE {
NOT_STARTED, NOT_STARTED,
FIX_LATER, FIX_LATER,
NOOP,
RUNNING, RUNNING,
COMPLETED, COMPLETED,
COMPLETED_WITH_ERRORS, COMPLETED_WITH_ERRORS,
@ -38,6 +39,9 @@ function Message(props: { fixState: FIX_STATE }) {
case FIX_STATE.COMPLETED: case FIX_STATE.COMPLETED:
message = constants.REPLACE_THUMBNAIL_COMPLETED(); message = constants.REPLACE_THUMBNAIL_COMPLETED();
break; break;
case FIX_STATE.NOOP:
message = constants.REPLACE_THUMBNAIL_NOOP();
break;
case FIX_STATE.COMPLETED_WITH_ERRORS: case FIX_STATE.COMPLETED_WITH_ERRORS:
message = constants.REPLACE_THUMBNAIL_COMPLETED_WITH_ERROR(); message = constants.REPLACE_THUMBNAIL_COMPLETED_WITH_ERROR();
break; break;
@ -64,6 +68,10 @@ export default function FixLargeThumbnails(props: Props) {
fixState = FIX_STATE.NOT_STARTED; fixState = FIX_STATE.NOT_STARTED;
updateFixState(fixState); updateFixState(fixState);
} }
if (fixState === FIX_STATE.COMPLETED) {
fixState = FIX_STATE.NOOP;
updateFixState(fixState);
}
setFixState(fixState); setFixState(fixState);
return fixState; return fixState;
}; };
@ -83,14 +91,14 @@ export default function FixLargeThumbnails(props: Props) {
props.show(); props.show();
} }
if ( if (
fixState === FIX_STATE.COMPLETED && (fixState === FIX_STATE.COMPLETED || fixState === FIX_STATE.NOOP) &&
largeThumbnailFiles.length > 0 largeThumbnailFiles.length > 0
) { ) {
updateFixState(FIX_STATE.NOT_STARTED); updateFixState(FIX_STATE.NOT_STARTED);
logError(Error(), 'large thumbnail files left after migration'); logError(Error(), 'large thumbnail files left after migration');
} }
if (largeThumbnailFiles.length === 0) { if (largeThumbnailFiles.length === 0 && fixState !== FIX_STATE.NOOP) {
updateFixState(FIX_STATE.COMPLETED); updateFixState(FIX_STATE.NOOP);
} }
}; };
useEffect(() => { useEffect(() => {

View file

@ -590,6 +590,9 @@ const englishConstants = {
REPLACE_THUMBNAIL_COMPLETED: () => ( REPLACE_THUMBNAIL_COMPLETED: () => (
<>successfully compressed all thumbnails</> <>successfully compressed all thumbnails</>
), ),
REPLACE_THUMBNAIL_NOOP: () => (
<>you have no thumbnails that can be compressed further</>
),
REPLACE_THUMBNAIL_COMPLETED_WITH_ERROR: () => ( REPLACE_THUMBNAIL_COMPLETED_WITH_ERROR: () => (
<>could not compress some of your thumbnails, please retry</> <>could not compress some of your thumbnails, please retry</>
), ),