-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup: Lots of fixes, refactoring and documentation #887
Changes from 17 commits
d0597f6
826d3c5
a17d491
fe5822f
d332981
b5d3084
ce52f19
82ba33b
2a1d096
84c256b
a187a28
1d9348e
9b50fba
321c68d
d7ba638
c4aa505
d0cfea6
f7cf0f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '/app/domain/backup/hooks/useInitBackup' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useEffect } from 'react' | ||
|
||
import { useClient } from 'cozy-client' | ||
|
||
import { | ||
getLocalBackupConfig, | ||
setBackupAsToDo | ||
} from '/app/domain/backup/services/manageLocalBackupConfig' | ||
|
||
import Minilog from 'cozy-minilog' | ||
|
||
const log = Minilog('💿 Backup') | ||
|
||
export const useInitBackup = (): void => { | ||
const client = useClient() | ||
|
||
useEffect(() => { | ||
const checkAndFixIfBackupStuckInRunning = async (): Promise<void> => { | ||
if (!client) { | ||
return | ||
} | ||
|
||
const backupConfig = await getLocalBackupConfig(client) | ||
|
||
if (backupConfig.currentBackup.status === 'running') { | ||
log.debug('A running backup has been set as to do.') | ||
await setBackupAsToDo(client) | ||
} | ||
} | ||
|
||
void checkAndFixIfBackupStuckInRunning() | ||
}, [client]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we ensure this is called only on startup if there is a dependency on client? (however if the client changes I suppose it is expected to clear the backup status) |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error.errors content should be checked first here to prevent undefined access error if
error[0]
does not exist