Solved xbmcvfs handling of rmdir function
#1
Someone posted an Issue on the GitHub for my Backup Addon that has me wondering about the rmdir() function in the xbmcvfs Python module. 

In previous versions of the addon I've always used the rmdir() function to clean up old Backup archives files based on the user's defined rotation preference. Since the release of Kodi 19 this hasn't been working. Testing on different file systems confirms errors trying to delete directories that still have files in them. As a test I wrote a quick function to recursively delete files/folders in a loop. This worked and everything was removed properly. 

My question is: did something change with the rmdir() function? Does it now require an empty directory or you get an error? I did some searching and couldn't find a definitive answer. If that's the case I can use my loop to clean it out; just confusing since this has always worked previously. Want to make sure it's a "feature" not a "bug" before attempting a work around. 

Link to issue: 
https://github.com/robweber/xbmcbackup/issues/186

Line in the Matrix version of addon (pretty sure this worked in Alpha versions):
https://github.com/robweber/xbmcbackup/b...up.py#L491

Same code line in Krypton/Leia compatible version. 
https://github.com/robweber/xbmcbackup/b...up.py#L473
Reply
#2
I am not aware of any changes here. Out of curiosity can you try xbmcvfs.rmdir(dir, force=True) to check if it makes any difference?
Reply
#3
(2021-03-14, 20:48)enen92 Wrote: I am not aware of any changes here. Out of curiosity can you try xbmcvfs.rmdir(dir, force=True) to check if it makes any difference?

I just tried with force=True and that seems to have done the trick - thanks. Any reason that argument isn't documented in the Pydocs? https://codedocs.xyz/xbmc/xbmc/group__py...830fde8962
Reply
#4
That's a good question, I'll add it.

edit: added in https://github.com/xbmc/xbmc/pull/19430
edit2: thread marked solved
Reply
#5
i tried 
     xbmcvfs.rmdir(folder_path, force=True)
and
     xbmcvfs.rmdir(folder_path, True)

but in both cases it is not deleting the folder if there are any files left within that folder
(kodi 21.1)
Reply

Logout Mark Read Team Forum Stats Members Help
xbmcvfs handling of rmdir function0