mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Kobo driver: Delete empty directories in root
These accumulate over time if user deletes books on device rather than via calibre.
This commit is contained in:
parent
e40228cb84
commit
f637014ad1
@ -17,7 +17,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
from contextlib import closing
|
from contextlib import closing, suppress
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from calibre import fsync, prints, strftime
|
from calibre import fsync, prints, strftime
|
||||||
@ -1631,6 +1631,17 @@ class KOBOTOUCH(KOBO):
|
|||||||
self.set_device_name()
|
self.set_device_name()
|
||||||
return super().get_device_information(end_session)
|
return super().get_device_information(end_session)
|
||||||
|
|
||||||
|
def post_open_callback(self):
|
||||||
|
# delete empty directories in root they get left behind when deleting
|
||||||
|
# books on device.
|
||||||
|
for prefix in (self._main_prefix, self._card_a_prefix, self._card_b_prefix):
|
||||||
|
if prefix:
|
||||||
|
with suppress(OSError):
|
||||||
|
for de in os.scandir(prefix):
|
||||||
|
if not de.name.startswith('.') and de.is_dir():
|
||||||
|
with suppress(OSError):
|
||||||
|
os.rmdir(de.path)
|
||||||
|
|
||||||
def open_linux(self):
|
def open_linux(self):
|
||||||
super().open_linux()
|
super().open_linux()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user