Skip to content

Commit

Permalink
[Reverse-Sync-14-02-2024] : Sunbird Integration & Data Backup and Res…
Browse files Browse the repository at this point in the history
…tore Implementation (#1261)

* fix cancel download popup not shown

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* fix: show tuvali version

Co-authored-by: vijay151096 <94220135+vijay151096@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* downgrade tuvali version to 0.4.6 for qa testing (#1149)

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* Revert "downgrade tuvali version to 0.4.6 for qa testing (#1149)"

This reverts commit 633f42f.

Signed-off-by: Swati Goel <meet2swati@gmail.com>

* Resetting the Data_Backup Toggle (#1202)

* [INJI-766] set backupAndRestore env variable to true and remove full stop in the kan langugage in one of the help page question

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* [INJI-766] remove backupAndRestore variable from env file

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* Revert "Merge pull request #1227 from tw-mosip/internal-release-01-02-2024" (#1242)

This reverts commit 6de62fc, reversing
changes made to f63445f.

Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>

* [Internal-Release-20+] : Sunbird Changes (#1243)

* [INJIMOB-683]: add testid for missed vc field (#1226)

* [INJIMOB-683]: add testid for missed vc field

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* [INJIMOB-683]: add testidprops for missed vc field

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* [INJIMOB-683]: add testidprops for missed vc field

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

---------

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* [INJIMOB-770]: parse date received in the vc's (#1225)

* [INJIMOB-770]: parse date received in the vc's

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* [INJIMOB-770]: parse date received in the vc's

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

---------

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* downgrade cocoapods version (#1231)

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>
Co-authored-by: adityankannan-tw <adityan410pm@gmail.com>

* Use latest cocoapods version (#1236)

* downgrade cocoapods version

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>

* use latest cocoapods version

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>

---------

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>
Signed-off-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
Co-authored-by: adityankannan-tw <adityan410pm@gmail.com>

---------

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>
Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>
Signed-off-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
Co-authored-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
Co-authored-by: adityankannan-tw <adityan410pm@gmail.com>

* [INJIMOB-760]: update mosip Logo

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

* [INJIMOB-834] ignore corrupted VC while performing backup

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-834] remove corrupted VC metaData while performing backup

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] add backup & restore in iOS (iCloud) (#119)

* [INJIMOB-752] - Added basic backup and restore flow for iCloud

Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>

* [INJIMOB-752] show proceed screen based on stored value

Co-authored-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] fetch last backup details of iCloud

Co-authored-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] download any unsynced files during lang setup in iOS

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] show permision required screen when not signed in on iOS

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] retry to sync unsynced file if exists while fetching last backup details

Co-authored-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] - Added sync and open settings

Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>

* [INJIMOB-752] - Add missing translations and refactor

Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>

* [INJIMOB-752] - refactoring

Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>

* [INJIMOB-834] ignore corrupted VC while performing backup (#1253)

* [INJIMOB-834] ignore corrupted VC while performing backup

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-834] remove corrupted VC metaData while performing backup

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

---------

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] download any unsynced files during lang setup in iOS

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] remove backup and restore toggle

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] sync style of newLabel in purple and default theme

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] remove debug logs

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] rename file googleCloudUtils to CloudBackupAndRestoreUtils

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] return no backup faile error when backupfiles list from cloud is empty

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] add initail state in downloadingCredential to fix warning

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>

* [INJIMOB-752] - Added delayed visibility for backup screen

Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>

---------

Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>
Co-authored-by: Sreenadh S <32409698+sree96@users.noreply.github.com>

* [INJIMOB-787] Conditional restore of VCs (#120)

* [INJI-787] add bootstrap state for restarting restore ops

Notes:
- all operations depend on the state of the $DOCUMENT_DIR/inji/backup/
  directory contents and not on the state of the MMKV DB

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

* [INJI-787] conditional restore on restart of restore

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

* [INJIMOB-787] fix recent file finder code

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

* [INJIMOB-787] add vc remove logic for partial restore

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

* [INJIMOB-787] refactor, ACK reviews, rm dead condition

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

* [INJIMOB-787] remove console.logs

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

* [INJIMOB-787] remove irrelevant TODOs

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

---------

Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>

* Revert "Inji mob 737 rtl issue (#1238)"

This reverts commit 2665cde.

* [INJIMOB-760]: adjust the mosip logo in the issuer section

Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>

---------

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>
Signed-off-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
Signed-off-by: Swati Goel <meet2swati@gmail.com>
Signed-off-by: Vijay <94220135+vijay151096@users.noreply.github.com>
Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>
Signed-off-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Signed-off-by: Harsh Vardhan <harsh59v@gmail.com>
Co-authored-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>
Co-authored-by: Swati Goel <meet2swati@gmail.com>
Co-authored-by: PuBHARGAVI <46226958+PuBHARGAVI@users.noreply.github.com>
Co-authored-by: Pooja Babusingh <68894211+PoojaBabusingh@users.noreply.github.com>
Co-authored-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
Co-authored-by: adityankannan-tw <adityan410pm@gmail.com>
Co-authored-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Co-authored-by: Harsh Vardhan <harsh59v@gmail.com>
  • Loading branch information
9 people authored Feb 15, 2024
1 parent b45bf5b commit 10a72a6
Show file tree
Hide file tree
Showing 19 changed files with 296 additions and 225 deletions.
24 changes: 14 additions & 10 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fileignoreconfig:
- filename: shared/telemetry/TelemetryUtils.js
checksum: ffe9aac2dcc590b98b0d588885c088eff189504ade653a77f74b67312bfd27ad
- filename: shared/fileStorage.ts
checksum: 451e8873a635d955fe426d9a5fcf191f2d4fd74984a1a4518760e2d10e9e1817
checksum: 2ba2721d9722cd9420ae26762316230f7dab1a0be45820cbda4d0ecae0edf957
- filename: screens/Issuers/IssuersScreen.tsx
checksum: 9c53e3770dbefe26e0de67ee4b7d5cc9c52d9823cbb136a1a5104dcb0a101071
- filename: ios/Podfile.lock
Expand Down Expand Up @@ -116,13 +116,13 @@ fileignoreconfig:
- filename: .github/workflows/android-custom-build.yml
checksum: 4d155c6e5468effb0b82e62f6878f2bd7ff7e7c9540e16bdd28cb81b80672ac3
- filename: .github/workflows/push-triggers.yml
checksum: 4a031b46646aa982c8f40e4c7fe0bd3e05a76a6af1ff1c2de7350ba6ebf9a839
checksum: 4a031b46646aa982c8f40e4c7fe0bd3e05a76a6af1ff1c2de7350ba6ebf9a839
- filename: components/VC/Views/VCCardViewContent.tsx
checksum: 02655ff3d7f8a8ea4f3664485f98c961802c598242ec44408594a2ddb721fa5e
- filename: screens/Settings/BackupController.tsx
checksum: 4a031b46646aa982c8f40e4c7fe0bd3e05a76a6af1ff1c2de7350ba6ebf9a839
- filename: machines/backupRestore.typegen.ts
checksum: 67925a7ee485ab3ba4c6345340ad6598746717984c0506f1ced1716fb68b5aa4
checksum: ac9c154060c7c1adb3392ac8c78a42cae5ca3faea3b4b0166dd00d4ca38b290d
- filename: machines/settings.typegen.ts
checksum: e4ae05822f1b1c23f3f70d03dd46fd8f29ba6b52d40f2f24c121f536fbb5f2c4
- filename: .env
Expand All @@ -140,7 +140,7 @@ fileignoreconfig:
- filename: ios/fastlane/Fastfile
checksum: a4e3772dc67a07ecbcfc58be0d6d4f7fa799cec7ac25bd269ac29459c8669ca4
- filename: shared/storage.ts
checksum: c0e99e00d260c665dcf87d09b1ed75a4e73cb9eeb2036ccb021560d1d643489f
checksum: c83024929b59f76cce188dbe09eb3af1803d3a08f867feb7478137ddabc3bfdc
- filename: injitest/src/test/java/iosTestCases/CredentialRegistryTest.java
checksum: b0808e0c511412cde21fd169a9bbeaf3b77cb48f25418e12d341cc3ce1df5898
- filename: machines/backupAndRestore/backupAndRestore.typegen.ts
Expand All @@ -167,24 +167,28 @@ fileignoreconfig:
- filename: locales/fil.json
checksum: 29193fd3b14b7332bf7a485f659197002f29a58af88ed0653cae262e7254c84d
- filename: screens/Home/IntroSlidersScreen.tsx
checksum: af4a7e2d04b1141b7c32acfabeb3213a32eaca2a8e8f61e6958b6c97219dce57
checksum: af4a7e2d04b1141b7c32acfabeb3213a32eaca2a8e8f61e6958b6c97219dce57
- filename: screens/Home/MyVcs/GetIdInputModal.tsx
checksum: 067664e19817d3aba98b0cfa68ef57a04958a982ee23b96b612e4bf466a73890
- filename: screens/PasscodeScreen.tsx
checksum: 9af4308001e7e260ffffd26955ca49df3b388e34686509371e23dd837b11d030
- filename: screens/Home/MyVcs/IdInputModal.tsx
checksum: b735aedc84164d03c199fe89ccbf9df58f8997bfb4f60e7058a22bfe952fda3e
- filename: .github/workflows/ui-automation.yml
checksum: 0b26a5dcb7524ba15d6aaeaf04f2ef94be9d25ef702d9072d6628bcd58e50f36
checksum: 0b26a5dcb7524ba15d6aaeaf04f2ef94be9d25ef702d9072d6628bcd58e50f36
- filename: components/BannerNotificationContainer.tsx
checksum: a98ff1a0dd96d3ead4b8191320be8b0c7a558cda6b0de39f1c62aaa8efef9fb8
checksum: a98ff1a0dd96d3ead4b8191320be8b0c7a558cda6b0de39f1c62aaa8efef9fb8
- filename: components/HelpScreen.tsx
checksum: bbc69143bd37d065bba3800396301db5a0318e8b7ba51ecd49142dda68783a01
checksum: bbc69143bd37d065bba3800396301db5a0318e8b7ba51ecd49142dda68783a01
- filename: machines/backupRestore.ts
checksum: 94bbbe550c3e6ba77f66252fc62e9659236ce880bca44fc05f5bd8170e9c6388
checksum: 433cecb9295c7052731600d16c601c1b6df9cc5a1b9f435423f81aae54d33d47
- filename: machines/backupAndRestore/backupAndRestoreSetup.ts
checksum: 75b07071aef4278f40f16861232b922e5ee8594efc9467984b072966fa7793b8
- filename: machines/backupAndRestore/backupAndRestoreSetup.typegen.ts
checksum: ad12de520a68fbd43560474ded24edf25a02f6ec90b67c726d6c5dedb579eb83
- filename: machines/backupAndRestore/backupAndRestoreSetup.ts
checksum: 1822e1966c97649cf9ee8892fbca143128003234d59ca754e0527feaf769f162
checksum: 397f2076504f851a981b0deff6eeac30041c775ee1c57b51e328fc09d52ef43e
- filename: shared/VCMetadata.ts
checksum: e93f988415bf91064e2cf5fbc09ff6c7226798baa5da721fa0715d5d0d6afddf
version: ""

31 changes: 8 additions & 23 deletions components/ui/themes/DefaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,17 @@ export const DefaultTheme = {
height: 173.276,
},
logo: {
height: 40,
width: 40,
height: 65,
width: 65,
},
issuerLogo: {
resizeMode: 'contain',
aspectRatio: 1,
height: 60,
},
vcDetailsLogo: {
height: 50,
width: 50,
height: 65,
width: 65,
},
homeCloseCardDetailsHeader: {
flex: 1,
Expand Down Expand Up @@ -431,7 +431,6 @@ export const DefaultTheme = {
height: 36,
borderRadius: 10,
backgroundColor: Colors.LightOrange,
justifyContent: 'center',
},
cameraFlipIcon: {
height: 42,
Expand Down Expand Up @@ -490,6 +489,10 @@ export const DefaultTheme = {
paddingVertical: 9,
justifyContent: 'space-between',
},
iconContainer: {
flexDirection: 'row',
alignItems: 'flex-end',
},
scannerContainer: {
borderRadius: 24,
alignSelf: 'center',
Expand Down Expand Up @@ -670,24 +673,6 @@ export const DefaultTheme = {
fontFamily: 'Inter_700Bold',
lineHeight: 12,
},
scanLayoutHeaderContainer: {
flex: 1,
flexDirection: 'row',
marginLeft: I18nManager.isRTL ? 40 : 15,
marginTop: 15,
},
scanLayoutHeaderTitle: {
fontSize: 26,
fontFamily: 'Inter_600SemiBold',
paddingTop: 20,
paddingBottom: 10,
},
sendVcHeaderContainer: {
flex: 1,
flexDirection: 'row',
marginLeft: I18nManager.isRTL ? 50 : 0,
marginTop: 15,
},
}),
BannerStyles: StyleSheet.create({
container: {
Expand Down
31 changes: 8 additions & 23 deletions components/ui/themes/PurpleTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,17 +375,17 @@ export const PurpleTheme = {
height: 173.276,
},
logo: {
width: 40,
height: 40,
height: 65,
width: 65,
},
issuerLogo: {
resizeMode: 'contain',
aspectRatio: 1,
height: 60,
},
vcDetailsLogo: {
width: 50,
height: 50,
height: 65,
width: 65,
},
homeCloseCardDetailsHeader: {
flex: 1,
Expand Down Expand Up @@ -436,7 +436,6 @@ export const PurpleTheme = {
height: 36,
borderRadius: 10,
backgroundColor: Colors.LightPurple,
justifyContent: 'center',
},
cameraFlipIcon: {
width: 42,
Expand Down Expand Up @@ -494,6 +493,10 @@ export const PurpleTheme = {
paddingVertical: 9,
justifyContent: 'space-between',
},
iconContainer: {
flexDirection: 'row',
alignItems: 'flex-end',
},
scannerContainer: {
borderRadius: 24,
alignSelf: 'center',
Expand Down Expand Up @@ -674,24 +677,6 @@ export const PurpleTheme = {
fontFamily: 'Inter_700Bold',
lineHeight: 12,
},
scanLayoutHeaderContainer: {
flex: 1,
flexDirection: 'row',
marginLeft: I18nManager.isRTL ? 40 : 15,
marginTop: 15,
},
scanLayoutHeaderTitle: {
fontSize: 26,
fontFamily: 'Inter_600SemiBold',
paddingTop: 20,
paddingBottom: 10,
},
sendVcHeaderContainer: {
flex: 1,
flexDirection: 'row',
marginLeft: I18nManager.isRTL ? 50 : 0,
marginTop: 15,
},
}),
BannerStyles: StyleSheet.create({
container: {
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = '1' if podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR'] == 'true'

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
install! 'cocoapods',
:deterministic_uuids => false

prepare_react_native_project!
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,6 @@ SPEC CHECKSUMS:
Yoga: 065f0b74dba4832d6e328238de46eb72c5de9556
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb

PODFILE CHECKSUM: 01f58b130fa221dabb14b2d82d981ef24dcaba53
PODFILE CHECKSUM: 90dfa5dbb6ca0103a4e49014140523aff5458f68

COCOAPODS: 1.15.2
87 changes: 76 additions & 11 deletions machines/backupRestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {createModel} from 'xstate/lib/model';
import {AppServices} from '../shared/GlobalContext';
import fileStorage, {
backupDirectoryPath,
findMostRecentBackupFile,
getBackupFilePath,
unZipAndRemoveFile,
} from '../shared/fileStorage';
Expand Down Expand Up @@ -46,6 +47,7 @@ export const BackupRestoreEvents = model.events;

export const backupRestoreMachine = model.createMachine(
{
/** @xstate-layout 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 */
predictableActionArguments: true,
preserveActionOrder: true,
tsTypes: {} as import('./backupRestore.typegen').Typegen0,
Expand All @@ -54,25 +56,34 @@ export const backupRestoreMachine = model.createMachine(
events: {} as EventFrom<typeof model>,
},
id: 'backupRestore',
initial: 'init',
on: {
BACKUP_RESTORE: [
{
target: 'restoreBackup',
initial: 'preload',
states: {
preload: {
description:
'runs all pending restore migrations based on the state of the filestorage',
invoke: {
src: 'bootstrap',
onDone: [
{
cond: 'isBackupFile',
target: 'restoreBackup.readBackupFile',
},
{
target: 'init',
},
],
},
],
DOWNLOAD_UNSYNCED_BACKUP_FILES: {
actions: 'downloadUnsyncedBackupFiles',
},
},
states: {
init: {
on: {
BACKUP_RESTORE: [
{
target: 'restoreBackup',
},
],
DOWNLOAD_UNSYNCED_BACKUP_FILES: {
actions: 'downloadUnsyncedBackupFiles',
},
},
},
restoreBackup: {
Expand Down Expand Up @@ -241,11 +252,53 @@ export const backupRestoreMachine = model.createMachine(
},

services: {
bootstrap: context => async () => {
const bkpDIR = await fileStorage.exists(backupDirectoryPath);
// 1. Does anything even exists?
if (!bkpDIR) {
// noop: nothing exists, quit
return '';
}
// 2. Check for .injibackup file
const bkpFile = await findMostRecentBackupFile(
backupDirectoryPath,
'injibackup',
);
if (bkpFile !== '') {
context.fileName = bkpFile;
return context.fileName;
}
// 3. Check for .zip files
const ZIPfile = await findMostRecentBackupFile();
if (ZIPfile === '') {
return '';
}
// go to loadBackupFile
// 4. Check for corrupted ZIP
let filePath = '';
try {
(filePath = await unZipAndRemoveFile(ZIPfile.split('.zip')[0])),
(context.fileName = filePath.split('/inji/backup/')[1]);
return getFileNameFromZIPfile(context.fileName);
} catch (_) {
console.log('got error during unzip deleting the zip');
await fileStorage.removeItem(backupDirectoryPath);
/*
Android Errors:
- Couldn’t open file...
- Failed to extract file...
iOS Errors:
- unzip_error...
*/
return '';
}
},
checkStorageAvailability: () => async () => {
return await Storage.isMinimumLimitReached('minStorageRequired');
},
deleteBkpDir: () => async () =>
fileStorage.removeItem(backupDirectoryPath),
(await fileStorage.exists(backupDirectoryPath)) &&
(await fileStorage.removeItem(backupDirectoryPath)),

downloadLatestBackup: () => async () => {
const backupFileName = await Cloud.downloadLatestBackup();
Expand All @@ -259,6 +312,10 @@ export const backupRestoreMachine = model.createMachine(
return await unZipAndRemoveFile(context.fileName);
},
readBackupFile: context => async callback => {
// trim extension
context.fileName = context.fileName.endsWith('.injibackup')
? context.fileName.split('.injibackup')[0]
: context.fileName;
const dataFromBackupFile = await fileStorage.readFile(
getBackupFilePath(context.fileName),
);
Expand All @@ -267,6 +324,7 @@ export const backupRestoreMachine = model.createMachine(
},

guards: {
isBackupFile: (_, event) => event.data.endsWith('.injibackup'),
isMinimumStorageRequiredForBackupRestorationReached: (_context, event) =>
Boolean(event.data),
},
Expand Down Expand Up @@ -299,3 +357,10 @@ export function selectIsBackUpRestoreFailure(state: State) {
return state.matches('restoreBackup.failure');
}
type State = StateFrom<typeof backupRestoreMachine>;

function getFileNameFromZIPfile(fileName: string): string {
if (fileName.endsWith('.zip')) {
return fileName.split('.zip')[0] + '.injibackup';
}
return fileName + '.injiBackup';
}
Loading

0 comments on commit 10a72a6

Please sign in to comment.