Skip to content

Comments

Fix/error loading backup folder list#249

Open
egalvis27 wants to merge 9 commits intomainfrom
fix/error-loading-backup-folder-list
Open

Fix/error loading backup folder list#249
egalvis27 wants to merge 9 commits intomainfrom
fix/error-loading-backup-folder-list

Conversation

@egalvis27
Copy link

What is Changed / Added


In a subsequent PR, a function necessary to recover the backup list was removed. It has been added back, and the option to re-add folders when they already exist remotely but were lost in the local list has also been added.

Why

Comment on lines 26 to 32
function saveConfig() {
const user = getUser();
if (!user) {
return;
}

const { uuid } = user;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just pass the user's uuid and make the caller do the getUser, the way it is now it could be misleading with the early return.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

try {
if (!safeStorage.isEncryptionAvailable()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this would happen actually? that the safeStorage is not available

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export async function findBackupFolderByName({ deviceUuid, folderName }: Props) {
const { data: folder, error } = await fetchFolder(deviceUuid);
if (error) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just pass arround the error? This is could be misleading

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to return anything here. If the operation fails, the normal error flow of the backup folder creation function handles it automatically. The function either returns a folder on success or nothing on failure, which is sufficient.

if (error) return;

const existingFolder = folder.children.find((child) => child.plainName === folderName);
if (!existingFolder) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to return anything here. If the operation fails, the normal error flow of the backup folder creation function handles it automatically. The function either returns a folder on success or nothing on failure, which is sufficient.

@@ -10,21 +11,38 @@ type Props = {

export async function postBackup({ folderName, device }: Props) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, this method name should change since the method name does not really reflect the behaviour, since is creating or retrieving the already existing one

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants