Skip to content
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

✨ (llm|lld): delete local app data on uninstall and uninstallAll #7744

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

valpinkman
Copy link
Member

@valpinkman valpinkman commented Sep 4, 2024

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • delete app data when restore is finished (wip: handle UserRefusedOnDevice case)
    • updated the apprunner state to know when to delete app data backup during uninstall
    • refactor execWithTransport in its own file
    • update lld to use new flow
    • update llm to use new flow

📝 Description

This PR makes sure to remove local app data when uninstalling app through the manager on LLD/LLM + all changes required in LLC to make it work

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@valpinkman valpinkman requested review from a team as code owners September 4, 2024 09:50
Copy link

vercel bot commented Sep 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
web-tools ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 9, 2024 1:02pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-docs ⬜️ Ignored (Inspect) Visit Preview Sep 9, 2024 1:02pm
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Sep 9, 2024 1:02pm
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Sep 9, 2024 1:02pm
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Sep 9, 2024 1:02pm

@live-github-bot live-github-bot bot added desktop Has changes in LLD mobile Has changes in LLM common Has changes in live-common labels Sep 4, 2024
@valpinkman valpinkman changed the title ✨ (lld): delete local app data on uninstall and uninstallAll ✨ (desktop): delete local app data on uninstall and uninstallAll Sep 4, 2024
@valpinkman valpinkman force-pushed the feat/delete-app-data-after-restore branch from 9d11323 to 938e6b6 Compare September 4, 2024 12:10
@live-github-bot live-github-bot bot added the cli label Sep 4, 2024
@valpinkman valpinkman force-pushed the feat/delete-app-data-after-restore branch from 938e6b6 to 8ba07fc Compare September 4, 2024 12:50
@valpinkman valpinkman changed the title ✨ (desktop): delete local app data on uninstall and uninstallAll ✨ (llm|lld): delete local app data on uninstall and uninstallAll Sep 4, 2024
@valpinkman valpinkman force-pushed the feat/delete-app-data-after-restore branch 2 times, most recently from d2884b6 to 61a89c9 Compare September 5, 2024 12:55
subscriber.complete();
}),
// Delete the app data from the storage
switchMap(() => deleteAppData(appName, deviceModelId, storageProvider)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Interaction with data storage in this file is counter to the initial pattern.
This restoreAppData as well as backupAppData are dedicated to data stream programming. I think that the data deletion use case should be enchained in restoreAppDataUseCase where all the parameters are already present.

Copy link
Contributor

Choose a reason for hiding this comment

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

In addition, the deleting the local data is not part of the data restoration workflow. It is an operation independent and should not be injected into normal restoration workflow.

Copy link
Member Author

Choose a reason for hiding this comment

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

make sense, i will fix this

@@ -12,9 +12,9 @@ export default function uninstallAppWithBackup(
app: ApplicationVersion | App,
deviceId: DeviceModelId,
storage: StorageProvider<AppStorageType>,
shouldBackup: boolean = true,
deleteAppDataBackup: boolean = false,
Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger Sep 9, 2024

Choose a reason for hiding this comment

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

[SHOULD] The naming of deleteAppDataBackup is a bit strange because it doesn't match with what setting it to true will do, it doesn't actually delete any app data here (shouldBackup seemed much better to me it that's how it's supposed to work)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 46 to 61
expect(events).toHaveLength(5);
expect(events[0]).toEqual({
type: RestoreAppDataEventType.AppDataInitialized,
});
expect(events[1]).toEqual({
type: RestoreAppDataEventType.Progress,
data: expect.any(Number),
});
expect(events[2]).toEqual({
type: RestoreAppDataEventType.Progress,
data: expect.any(Number),
});
expect(events[3]).toEqual({
type: RestoreAppDataEventType.Progress,
data: expect.any(Number),
});
expect(events[4]).toEqual({
type: RestoreAppDataEventType.AppDataRestored,
});
done();
},
Copy link
Contributor

Choose a reason for hiding this comment

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

[SHOULD] if expect throws, done will never be called and the test will just be timing out, without an easy to read error message. In async tests with done, all expect should be surrounded with a try/catch with something like catch(caughtError) { done(caughtError) }

Copy link
Contributor

Choose a reason for hiding this comment

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

[ASK] Unrelated to the first comment: could use one expect(events).toEqual(expectedArray) instead of 5 expects, no ? Not crucial though

Copy link
Member Author

Choose a reason for hiding this comment

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

done

});
expect(events[4]).toEqual({
type: RestoreAppDataEventType.AppDataRestored,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

same comments as above

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -10,6 +10,7 @@ export type ExecArgs = {
app: App;
modelId?: DeviceModelId;
storage?: StorageProvider<AppStorageType>;
deleteAppDataBackup?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

[COULD] maybe add some TSdoc on those args

import uninstallApp from "../../hw/uninstallApp";
import uninstallAppWithBackup from "../../hw/uninstallAppWithBackup";

export const execWithTransport =
Copy link
Contributor

Choose a reason for hiding this comment

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

[COULD] Maybe it's worth adding a bit of TSDoc to explain what this does, and even potentially rename it to something less mysterious...

Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger left a comment

Choose a reason for hiding this comment

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

Some things to fix in async unit tests.
Also I think the name of the deleteAppDataBackup is maybe a bit too vague.
And I'm not sure I understand where the actual deletion of locally stored app data is done for app uninstallation, deleteAppDataUseCaseDI is never called in uninstall flows as far as I understand 🤔

@valpinkman
Copy link
Member Author

Some things to fix in async unit tests. Also I think the name of the deleteAppDataBackup is maybe a bit too vague. And I'm not sure I understand where the actual deletion of locally stored app data is done for app uninstallation, deleteAppDataUseCaseDI is never called in uninstall flows as far as I understand 🤔

Things are done here https://github.com/LedgerHQ/ledger-live/pull/7744/files#diff-cadd4d39653d7214faf8f5dd226d1a6e9c4fc35c45e66a08787170bcc9097d71 to know how to handle each case. (the state)
And there is no "deletion" when uninstalling https://github.com/LedgerHQ/ledger-live/pull/7744/files#diff-64aaf9798ce046311b2798bcaa0ebd94cf9c3308faf867ac000a861a6c150a87R19 we just skip the backup.

But fair point I will rename deleteAppDataBackup to make more sense

@valpinkman valpinkman force-pushed the feat/delete-app-data-after-restore branch from 6bd15b3 to 7e81505 Compare September 9, 2024 12:58
Copy link
Contributor

@ofreyssinet-ledger ofreyssinet-ledger left a comment

Choose a reason for hiding this comment

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

nice 👍

@valpinkman valpinkman merged commit 1e0eece into develop Sep 9, 2024
58 of 59 checks passed
@valpinkman valpinkman deleted the feat/delete-app-data-after-restore branch September 9, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli common Has changes in live-common desktop Has changes in LLD mobile Has changes in LLM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants