Skip to content

Commit

Permalink
CLI: Delete empty folders on download, update, pending (bug 1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardomiranda authored and thp committed May 17, 2014
1 parent f26aa50 commit 142214d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/gpo
Expand Up @@ -506,6 +506,7 @@ class gPodderCli(object):
'podcast': podcast.title})
self._finish_action(skip=True)

util.delete_empty_folders(gpodder.downloads)
safe_print(inblue(self._pending_message(count)))
return True

Expand All @@ -523,6 +524,7 @@ class gPodderCli(object):
safe_print(' ', episode.title)
count += 1

util.delete_empty_folders(gpodder.downloads)
safe_print(inblue(self._pending_message(count)))
return True

Expand Down Expand Up @@ -550,6 +552,7 @@ class gPodderCli(object):
self._download_episode(episode)
count += 1

util.delete_empty_folders(gpodder.downloads)
safe_print(count, 'episodes downloaded.')
return True

Expand Down
6 changes: 6 additions & 0 deletions src/gpodder/util.py
Expand Up @@ -1758,3 +1758,9 @@ def website_reachable(url):

return (False, None)

def delete_empty_folders(top):
for root, dirs, files in os.walk(top, topdown=False):
for name in dirs:
if not os.listdir(name):
os.rmdir(name)

1 comment on commit 142214d

@nkali
Copy link

@nkali nkali commented on 142214d Mar 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ignores folders populated only with the cover art files (but no podcast downloads): "folder.jpg", "folder.png" or "folder.gif".

Please sign in to comment.