Folders are not deleted after removing a torrent
-
- Member
- Posts: 13
- Joined: Fri Sep 02, 2022 1:38 pm
Folders are not deleted after removing a torrent
For some reason, in Deluge when I remove a torrent and tick "Include downloaded files", the torrent files are removed but the folders remain, is there any reason behind that, or is there a way for the folders to be deleted as well? Right now, I have a long list of empty folders for torrents which I have deleted in the past, and it's a bit of a hassle to manually go into each folder to verify if there is data or not before doing the cleanup.
Re: Folders are not deleted after removing a torrent
Hi Sindweller.
I tested this, but I cannot reproduce - folder + files are deleted fine here. I tested both GTKUI and webUI. Strange, and i'm affraid I don't know the reason for your issue.
Just so you don't think are ignored
I tested this, but I cannot reproduce - folder + files are deleted fine here. I tested both GTKUI and webUI. Strange, and i'm affraid I don't know the reason for your issue.
Just so you don't think are ignored

Re: Folders are not deleted after removing a torrent
I've seen this behavior myself, however reproducing it hasn't been something I've been able to do..it's happened with folders I've created using Move Download Folder, which I somewhat understood as it wasn't actual "torrent data" as well as occasionally (albeit rarely) with folders that were actually part of the data in the .torrent file, i.e. folder structure that the .torrent created, usually top-level. I'm not sure what caused this, however I think it might have had something to do with the folder being in use by something when it was being deleted. But that's just a guess. It wasn't often, and it wasn't something I found any pattern too.
Just want to affirm that I've seen this behavior myself....you're not crazy Sindweller

-
- Member
- Posts: 13
- Joined: Fri Sep 02, 2022 1:38 pm
Re: Folders are not deleted after removing a torrent
@mhertz, thank you for the reply mate, as always you are helpful! Also appreciate the time you took to try to reproduce!
Could my issue be related to the fact that I am using Deluge on Synology DSM? I noticed this behavior too when I used Transmission client, the folders stayed even after deleting torrents.
@ambipro, Glad for your affirmation haha
it could be as you say something to do with the folder being in use, I just need to figure out why or how Synology DSM may potentially be affecting this.
Could my issue be related to the fact that I am using Deluge on Synology DSM? I noticed this behavior too when I used Transmission client, the folders stayed even after deleting torrents.
@ambipro, Glad for your affirmation haha

Re: Folders are not deleted after removing a torrent
@Sindweller, Thanks bro!
I'm sorry to say I don't know if the synology plays any role in this, and somewhat guessing probably not after ambipro's helpfully input.
I googled the issue in general, after not finding anything dsm-specific neither, and your issue is reported intermittently for over a decade, and in other clients too.
One helpful reporter, together with Cas's help, found it only happened for him when the destination was on a remote smb or afp drive share, and when other laptop was connected to that at same time - didn't even need have the share opened either for this to happen. There would then be made hidden files like .thumbs.db or .ds_store in the folder, hence not deleted correctly.
Anyway, just adding this for just in case relevant, and sorry for noise if not.
viewtopic.php?f=7&t=41117

I googled the issue in general, after not finding anything dsm-specific neither, and your issue is reported intermittently for over a decade, and in other clients too.
One helpful reporter, together with Cas's help, found it only happened for him when the destination was on a remote smb or afp drive share, and when other laptop was connected to that at same time - didn't even need have the share opened either for this to happen. There would then be made hidden files like .thumbs.db or .ds_store in the folder, hence not deleted correctly.
Anyway, just adding this for just in case relevant, and sorry for noise if not.
viewtopic.php?f=7&t=41117
Re: Folders are not deleted after removing a torrent
I've had it happen on local drives on windows 7 and 10 both, x64. I don't think it's Synology specific. Perhaps something to do with the handles for the folder while seeding not being able to be released in a timely manner as it's being deleted? Just a speculative guess...Sindweller wrote: ↑Wed Dec 21, 2022 10:22 am @mhertz, thank you for the reply mate, as always you are helpful! Also appreciate the time you took to try to reproduce!
Could my issue be related to the fact that I am using Deluge on Synology DSM? I noticed this behavior too when I used Transmission client, the folders stayed even after deleting torrents.
@ambipro, Glad for your affirmation hahait could be as you say something to do with the folder being in use, I just need to figure out why or how Synology DSM may potentially be affecting this.
I know it's not a great solution, but there are plenty of ways to search and delete empty folders in both windows and linux :/
Re: Folders are not deleted after removing a torrent
Thanks for elaborating ambipro, and very well could be, sounds reasonable.
@all, I also did Google it shortly again, and saw another long thread(non-torrenting-related though), about folders with jpegs inside sometimes not deleting, speculated presumably because a .thumbs.db file open momentarily, despite never opening actual folder. A tip was given to disable generating these in group-policy-editor(gpedit) I believe was, as there only function anyway is helping compatability with old buggy programs one posted . So might check if such exist next time in the left undeleted folder(.thumbs.db)
Another thread about such issues(again non-torrenting-related) speculated because AV or index service having a file/dir handle open momentarily.
Last, I completely forgot that I intermittently had issues with deleting folders from windows batch-files, maybe 1 in 10 times, showing "Directory not empty" error when happens despite using /s switch to rd command hence on windows I always double that command twice in row, as never failed consecutively for me. I at that time googled it, and is described several places, as not only cmd commands affected, but also powershell and python etc, reason being that the underlying win32 API call has been designed little badly, and is prone to intermittent race conditions. If remember correct then the deletion happens asynchronous, files first and empty dirs last, so then sometimes the dir gets called for deletion before the actual files have been traversed finished for deletion, hence the error I got and possibly related here too.
Sorry for long babbling without providing any actual solution.
@all, I also did Google it shortly again, and saw another long thread(non-torrenting-related though), about folders with jpegs inside sometimes not deleting, speculated presumably because a .thumbs.db file open momentarily, despite never opening actual folder. A tip was given to disable generating these in group-policy-editor(gpedit) I believe was, as there only function anyway is helping compatability with old buggy programs one posted . So might check if such exist next time in the left undeleted folder(.thumbs.db)
Another thread about such issues(again non-torrenting-related) speculated because AV or index service having a file/dir handle open momentarily.
Last, I completely forgot that I intermittently had issues with deleting folders from windows batch-files, maybe 1 in 10 times, showing "Directory not empty" error when happens despite using /s switch to rd command hence on windows I always double that command twice in row, as never failed consecutively for me. I at that time googled it, and is described several places, as not only cmd commands affected, but also powershell and python etc, reason being that the underlying win32 API call has been designed little badly, and is prone to intermittent race conditions. If remember correct then the deletion happens asynchronous, files first and empty dirs last, so then sometimes the dir gets called for deletion before the actual files have been traversed finished for deletion, hence the error I got and possibly related here too.
Sorry for long babbling without providing any actual solution.
Re: Folders are not deleted after removing a torrent
I know he is having this issue on synology, but for windows it occurred to me that this might be a search indexer issue as well, trying to update the cache of directory listings? Not entirely sure but figured maybe someone with this issue could try disabling windows search indexing or whatever it's called and see if that solves their issue.
I had that thumbs.db problem with XP, but haven't since - I assume it may have been fixed, unsure. I don't use thumbnails or anything though anymore in folders, so that's probably another reason why it hasn't happened.
There is a program called "Unlocker" which I used to use to delete in-use folders/files that will literally show you the processes and handles a folder/file is being occupied with when you attempt to delete it, and allow you to kill the process, release the handle, and force the delete. May check into that although i doubt it would be helpful on synology, but perhaps if you see this happen live in the wild, and can go and check the handles on the folder and actively see a process (deluge, searchindex.exe, whatever) you can resolve the issue better?
Hope some of this helps someone.
I had that thumbs.db problem with XP, but haven't since - I assume it may have been fixed, unsure. I don't use thumbnails or anything though anymore in folders, so that's probably another reason why it hasn't happened.
There is a program called "Unlocker" which I used to use to delete in-use folders/files that will literally show you the processes and handles a folder/file is being occupied with when you attempt to delete it, and allow you to kill the process, release the handle, and force the delete. May check into that although i doubt it would be helpful on synology, but perhaps if you see this happen live in the wild, and can go and check the handles on the folder and actively see a process (deluge, searchindex.exe, whatever) you can resolve the issue better?
Hope some of this helps someone.