GNOME Bugzilla – Bug 149572
Automatic remove file from Trash if it was deleted longer then N days ago
Last modified: 2013-03-04 12:08:15 UTC
Now I have to manually empty the trash when I run out of disk space. I then always empty the complete trash (I'm lazy), but sometimes you then delete a file which you still needed. If I deleted a file e.g. 3 months ago it's very unlikely that I will need that file again. So it can be automatically deleted
*** This bug has been marked as a duplicate of 108413 ***
Not a duplicate. Bug 108413 is about deleting files from the Trash if that would free enough space to perform some action. This bug is about deleting files from the Trash after some time, regardless of free space. In <http://mail.gnome.org/archives/nautilus-list/ 2005-September/msg00054.html> I described how this could be presented in the Trash's Properties window: Automatically delete items from the Trash: [ Never :^] Menu items: "Never" (the default), "After 1 year", "After 3 months", "After 1 month", "After 1 week", "After 1 day", "When logging out", and "Immediately".
*** Bug 340706 has been marked as a duplicate of this bug. ***
I think the user sould not set a "timeout". The User should set a size limit! Here my orig. Feature Request: The user sould set a max size in percent of the partition size. If the trash is bigger than this max size, it should delete automatic the oldest files. So it can't fill the partition!
*** Bug 435213 has been marked as a duplicate of this bug. ***
*** Bug 556413 has been marked as a duplicate of this bug. ***
*** Bug 585910 has been marked as a duplicate of this bug. ***
*** Bug 619408 has been marked as a duplicate of this bug. ***
Dear all, I think we could propose 2 options in the Trash preferences : - some people (jens diemer and me) want to be sure that the partition won't be filled by the trash. Now in Gnome 2.30 (Ubuntu 10.04), a warning comes when a partition is nearly full (can someone tell me exactly the condition? and where to modify it?) that proposes to examine the disk, empty the trash or do nothing. So there could be an option to automatically empty the Trash when this condition (e.g. 500Mo left in the partition) is met. - some people want to delete automatically trashed files after a certain amount of time (e.g. "Never" (the default), "After 1 year", "After 3 months", "After 1 month", "After 1 week", "After 1 day", "When logging out", and "Immediately"). There could be another Trash option for this.
Nautilus devs: should this be reassigned to gnome-control-center's "Privacy and Sharing" component? Maybe it would be more fitting there. It could be set in the control center and then managed by gnome-settings-daemon thanks to the now standardized trash folders...?
Created attachment 229815 [details] [review] housekeeping: Add new settings for automatic purging of trash This commit adds new settings, 'purge-trash', 'purge-temp-files' and 'purge-after', which will be used for automatic purging of trash and temp files as part of the privacy panel implementation.
Created attachment 229816 [details] [review] housekeeping: Implement automatic purging of trash:// This commit reimplements the 'empty trash' functionality not to rely on nautilus, and adds an 'age' parameter. We install timeouts that check once every hour and purges trash and temporary files if they are older than the 'purge-after' setting allows. The timeouts only act if the 'purge-trash' or 'purge-temp-files' settings are TRUE.
Created attachment 229817 [details] [review] housekeeping: Port test to new trash purge api With the new gsd_ldsm_purge_trash call, gsd_ldsm_show_empty_trash has become redundant. Get rid of it.
Created attachment 229818 [details] [review] housekeeping: Add a D-Bus interface Export EmptyTrash and RemoveTempFiles methods on the bus. These will be used in the implementation of the privacy panel to allow on-the-spot purging.
On second thought, these settings are better off in the new privacy schema.
Created attachment 229836 [details] [review] Use the settings from the privacy schema
Review of attachment 229815 [details] [review]: As those are in gsettings-desktop-schemas now.
Review of attachment 229816 [details] [review]: ::: plugins/housekeeping/gsd-disk-space.c @@ +226,3 @@ +static GDateTime * +deletion_time_from_string (const gchar *date) Use g_time_val_from_iso8601() instead, and win! @@ +334,3 @@ + + if (del_children) { + enumerator = g_file_enumerate_children (file, This needs to be made completely async. @@ +344,3 @@ + (info = g_file_enumerator_next_file (enumerator, cancellable, NULL)) != NULL) { + child = g_file_get_child (file, g_file_info_get_name (info)); + delete_recursively_by_age (child, cancellable, age, TRUE, g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY); I don't think you need to go into the directory. The top-level directory is what will have a deletion-date, the rest will not. @@ +355,3 @@ + if (!g_cancellable_is_cancelled (cancellable) && del_file) { + if (should_purge_file (file, cancellable, age)) { + g_file_delete (file, cancellable, NULL); Add a dry-run #ifdef, so we can test this without trashing our data. @@ +929,3 @@ + + purge_trash_id = g_timeout_add_seconds (3600, ldsm_purge_trash, NULL); + purge_temp_id = g_timeout_add_seconds (3600, ldsm_purge_temp_files, NULL); In ldsm_purge_trash() and ldsm_purge_temp_files(), i would create a new GDateTime that you can compare each of the file with, rather than creating one for each and every file. You should also add a way to check for in-flight deletions (with a time change, i think you could have 2 timeouts starting on top of each other).
Review of attachment 229817 [details] [review]: ::: plugins/housekeeping/gsd-empty-trash-test.c @@ +36,3 @@ loop = g_main_loop_new (NULL, FALSE); + gsd_ldsm_purge_trash (0); This should probably use the dry-run mentioned in the previous review.
Review of attachment 229818 [details] [review]: Looks good.
Review of attachment 229836 [details] [review]: ::: plugins/housekeeping/gsd-disk-space.c @@ +890,3 @@ + purge_trash = g_settings_get_boolean (privacy_settings, SETTINGS_PURGE_TRASH); + purge_temp_files = g_settings_get_boolean (privacy_settings, SETTINGS_PURGE_TEMP_FILES); + purge_after = g_settings_get_uint (privacy_settings, SETTINGS_PURGE_AFTER); This needs to be updated for the changed setting names in gsettings-desktop-schemas.
Review of attachment 229836 [details] [review]: ::: plugins/housekeeping/gsd-disk-space.c @@ +962,3 @@ + if (privacy_settings != NULL) { + g_object_unref (privacy_settings); g_clear_object()?
Review of attachment 229816 [details] [review]: ::: plugins/housekeeping/gsd-disk-space.c @@ +303,3 @@ + } + + ctime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CHANGED); Use g_file_info_get_get_deletion_date() directly here.
Created attachment 230060 [details] [review] housekeeping: Implement automatic purging of trash and temp files
Created attachment 230061 [details] [review] bump required gsettings-desktop-schemas version
Created attachment 230062 [details] [review] housekeeping: Add a D-Bus interface
I couldn't get myself to do the async dance tonight.
Created attachment 230280 [details] [review] housekeeping: Implement automatic purging of trash and temp files
Created attachment 230281 [details] [review] bump required gsettings-desktop-schemas version
Created attachment 230282 [details] [review] housekeeping: Add a D-Bus interface
Created attachment 230283 [details] [review] Do the purging asynchronously
Attachment 230282 [details] pushed as 491fe91 - housekeeping: Add a D-Bus interface
Having "immediately" as a time option for emptying the trash is not needed as that is the same as permanently delete.
(In reply to comment #33) > Having "immediately" as a time option for emptying the trash is not needed as > that is the same as permanently delete. Which isn't offered as an option. The option also control when to purge temporary files.