Github Issue #8307 - Automatically clean up QubesIncoming directory if empty
on Jul 1, 2023 adw writes:
After copying or moving a file from one qube to another, a QubesIncoming directory is created along with suitable subdirectories. Usually, the user moves the file out of this directory structure in order to make use of the file. This often leaves behind an empty QubesIncoming directory (often with empty subdirectories). These persist until the user manually cleans them up.
And suggests
Automatically remove the empty QubesIncoming directory whenever the qube starts up or shuts down (not sure which is better). For present purposes:
Diagnosis and Analysis
None
Solution
This is extremely easy to fix. The "find(1)" command could find and delete empty files and empty directories. It is only necessary to add the proper ‘find’ command to a post-startup or pre-shutdown script. I personally prefer a pre-shutdown script (if available).
I will wait for one week to see if anyone else is willing to send the PR, then will act myself.
Deleting the empty (zero-bytes) files might not be necessary but does not harm. A scenario where empty files were left in the QubesIncoming folder could be envisioned.
find /home/user/QubesIncoming -type d -empty -delete
Will remove all the empty directories inside all subdirectories which could be unwanted.
I guess it’s better to add -maxdepth 1 so it’ll only remove the empty directories in /home/user/QubesIncoming:
find /home/user/QubesIncoming -maxdepth 1 -type d -empty -delete
Or search all the subdirectories and remove the parent directory only if there are no files present.
I don’t think there is a need to remove the empty files.
The empty files are different from the empty directories. The empty directories left after user moved their content to the different directory are expected to be unneeded, but empty files would’ve been created by user with some purpose in mind and I don’t think it’s ok to remove them.
@kenosen Maybe it would be better to keep the empty files as @apparatus suggests. I would suggest waiting for other opinions and act accordingly after having a majority consensus.
@adw Since you opened the original issue, what is your suggestion?
Deleting the QubesIncoming on shutdown regardless of it’s content (I do not like this).
Deleting the empty files and empty directories inside QubesIncoming recursively
Deleting the only the empty directories at dept 1
cc. @solene Who has made suggestion about this before.
A is a regular file? If yes, that is what I expected (i.e. 1/1/2 & 1/2 to be deleted).
p.s. The reason I liked the idea of deleting empty (zero size) files was that it would actually delete 'A'
OK. I think It would be better to wait and see what would adw and solene (and others) would suggest. I am OK with both scenario 2 & 3 which I mentioned earlier.
I personally need to keep QubesIncoming as it’s bookmarked in my file manager, the bookmark is removed if the directory disappear, it would be really annoying if it’s an opt-out feature.