Repository navigation
transaction: Add delete app data option - #6728
Conversation
01d8468 to
4764f3b
Compare
4764f3b to
1154be5
Compare
|
This really needs to be split up but most importantly needs a motivation (ideally in the PR description and the commits). |
|
Is this shape for splitting commits fine? I would then rework like this:
|
|
Sure, seems reasonable. |
bbaa11e to
6c0838c
Compare
|
You really need to work on your commit splitting and commit messages. For one, the formatting: 80 chars per line. The first two commits don't give me enough information. The commit message tells me exactly the same as looking at the code, but not why (mention the broader goal), and not how (improve? seems like two commits, one removing the XdpDbusPermissionStore argument, one improving ownership). |
|
The broader goal is only archived by the 1st and last commits in tandem. I guess I can mention that there again, but it feels weird, as it's not complete without the third commit. (and was one of the reasons this was one commit in the first place) I can split up the 2nd one or drop it and focus on the other commits. It's not needed, just removing an unused param and modernizing the pointer logic. (but my C is still very rusty, so happy to drop that) Edit: Filled in the description in addition |
|
The first commit is just "common: Move app data helpers out of builtins". I can see that. Why though? It only becomes clear when you reach the third commit. Just adding "We're going to expose them in libflatpak in a few commits" to the body is enough for a reviewer to understand. The improvements in the second commit are good. It only needs to be split appropriately and have a message which isn't just "Improve things". Say what you're improving. I know this can be annoying but it's an important part to get right and once you get it, it becomes pretty easy. |
|
No, it's totally fine, I was in a rush yesterday and shouldn't have pushed. |
6c0838c to
e721335
Compare
|
Should the commit header also be shorter? |
| install : true, | ||
| install_dir : docdir, | ||
| ) | ||
| endif |
There was a problem hiding this comment.
Seems like an extra newline snuck in here.
| @@ -131,8 +131,5 @@ flatpak_delete_app_data (const char *app_id, | |||
| return FALSE; | |||
There was a problem hiding this comment.
The prefix common is not helpful because it's too generic. Use app-data:.
|
|
||
| if (res) | ||
| { | ||
| if (priv->delete_data && flatpak_decomposed_is_app (op->ref)) |
There was a problem hiding this comment.
A few notes:
- Should this really be part of a transaction or of individual ops?
- If it is per-op, then I guess we should only allow this for apps when setting it
- What happens when this fails? The app has been uninstalled but the data has not been removed, now there is no way to remove the data via libflatpak.
There was a problem hiding this comment.
- you mean it's own operation?
- we do skip non apps - but this is still the transaction implementation (not sure I follow)
- Yeah, I actually iterated on this over the past days. But ended up here again as I don't think we can recover. We could give a better return, but that would probably not be as backwards compatible.
There was a problem hiding this comment.
you mean it's own operation?
Either that, or part of the uninstall op?
I mean, I'm not even sure if this really should be part of a transaction in the first place. Maybe it's fine to just provide a separate api to delete the data?
we do skip non apps - but this is still the transaction implementation (not sure I follow)
Right, my point is that if this were on the uninstall op, we could error out when constructing the transaction/op and it's not an app.
There was a problem hiding this comment.
Having it's own operation seems simpler for us, but might not be the ideal API. Which would you prefer?
Edit: Give me a gut feeling, I can explore from there
There was a problem hiding this comment.
Maybe try to answer the question what we get from it being part of a transaction? If there isn't a good reason, let's not make it part of a transaction.
There was a problem hiding this comment.
My feeling is, that having a separate method to call would be better - even if it causes some implementation detail on the apps that are using it.
But it also might allow cleaning up app data, when the app is not installed at all or resetting it with keeping the app installed.
There was a problem hiding this comment.
Alright, then let's do that instead.
dd805fe to
d266554
Compare
swick
left a comment
There was a problem hiding this comment.
Looks almost good. The merge commit needs to go and a few things should probably change.
Btw, if you want me to re-review something, please add a comment and say something.
| #include "flatpak-utils-private.h" | ||
|
|
||
| char ** | ||
| get_permission_tables (XdpDbusPermissionStore *store) |
There was a problem hiding this comment.
That doesn't seem to be the right place. The app data has nothing to do with the permission tables.
There was a problem hiding this comment.
Got it's own common file now
| gboolean | ||
| flatpak_delete_app_data (const char *app_id, | ||
| GError **error) | ||
| flatpak_delete_app_data_for_file (const char *app_id, |
There was a problem hiding this comment.
What's the purpose of flatpak_delete_app_data_for_file? We need an app id anyway, so why make it variable on the path?
There was a problem hiding this comment.
Got rid of it, don't remember why I did this.
| if (!flatpak_is_valid_name (app_id, -1, error)) | ||
| return FALSE; | ||
|
|
||
| path = g_build_filename (g_get_home_dir (), ".var", "app", app_id, NULL); |
There was a problem hiding this comment.
We have to be careful about paths. If any of the components is attacker controlled, a path can point to anywhere via symlinks. In this case everything is fine because ~/.var/app/$app_id is still all not attacker controlled (any path inside would be a vulnerability). Probably worth documenting.
6f8ec3e to
3849485
Compare
| * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| * Authors: | ||
| * Alexander Larsson <[email protected]> |
There was a problem hiding this comment.
This is inherited from app/flatpak-builtins-uninstall.c
3849485 to
62cb28b
Compare
|
@swick hopefully addesses everything |
|
|
||
| char ** get_permission_tables (XdpDbusPermissionStore *store); | ||
| gboolean flatpak_reset_permissions_for_app (const char *app_id, | ||
| GError **error); |
There was a problem hiding this comment.
Classic claude. It often fails to properly align things.
There was a problem hiding this comment.
Hopefully better now
| } | ||
|
|
||
| gboolean | ||
| flatpak_reset_permissions_for_app (const char *app_id, |
There was a problem hiding this comment.
So, two things:
- We have a
FlatpakPermissionstruct already, which makes this a bit awkard - The functions here don't operate on an object but are just a collection of useful things, so it's probably better to call it something
-utilsin the name (or find an existing utils file which fits)
There was a problem hiding this comment.
- not really sure, what you expect me to do here
- added -utils to the file name
|
|
||
| #include <gio/gio.h> | ||
|
|
||
| gboolean flatpak_delete_app_data (const char *app_id, |
There was a problem hiding this comment.
If the file is called flatpak-app-data, and we operate on the app data, it's better to name things accordingly: $prefix_$thing_$verb, so flatpak_app_data_delete
There was a problem hiding this comment.
Should be addressed
There was a problem hiding this comment.
Still flatpak_delete_app_data instead of flatpak_app_data_delete
fb5b5ef to
522f3a1
Compare
522f3a1 to
cea39b5
Compare
|
Rebase due to test changes |
| 'flatpak-app-data.c', | ||
| 'flatpak-appdata.c', |
|
|
||
| #include <gio/gio.h> | ||
|
|
||
| gboolean flatpak_delete_app_data (const char *app_id, |
There was a problem hiding this comment.
Still flatpak_delete_app_data instead of flatpak_app_data_delete
cea39b5 to
cb2d7d3
Compare
|
Mh, just calling the file |
Libflatpak needs to reuse user-data deletion and permission reset logic that was previously private to the command-line builtins. This will let software stores offer the equivalent of uninstall --delete-data. Move each concern into a separate common module without changing behavior so a public API can be added in a later commit. Name the user-data module and its helper consistently here, and keep them distinct from the existing appdata metadata code.
Return the permission reset result directly after app data removal. This keeps the success and error paths equivalent while removing an unnecessary conditional.
Use GLib's automatic string-vector cleanup for permission table lists. This makes ownership explicit and ensures early returns release the list.
Permission table discovery reads the on-disk database directory and does not use the D-Bus permission store proxy. Remove the unused argument and update callers.
cb2d7d3 to
db3a84c
Compare
Applications using libflatpak currently have to duplicate the CLI's private cleanup logic to offer the equivalent of uninstall --delete-data. Add a standalone API that removes ~/.var/app data and resets permission store entries without requiring the app to be installed. Keep it separate from transactions so callers can retry partial failures or reset data for an installed app. Validate app IDs before constructing paths, propagate cancellation and permission table errors, and document partial failure behavior.
db3a84c to
2c97205
Compare
Story here is, that I've read https://linuxnews.de/flatsweep-aufraeumhelfer-fuer-flatpak-reste/ and wondered, why there is even a need for an app like
flatsweepLooked a bit into it and there are legimate usecases, where flatpak can't remove the user data (e.g. its a system app and gets uninstalled by an admin while the user partition is not unlocked etc)
Then looked how stores like bazaar implement it right now and it turns out, they all need to roll their own logic.
So while you can run
flatpak remove my.demo.app --delete-datafrom the cli, there is no way to get that behavior via libflatpak.