When automatically sending news to device, send to main memory preferentially, if it has enough space. Fixes #8877 (Nook magazine default will not reset to main memory after setting to Card A)

This commit is contained in:
Kovid Goyal 2011-02-08 16:11:51 -07:00
parent bdd690df12
commit 806f6d7425

View File

@ -1026,6 +1026,17 @@ class DeviceMixin(object): # {{{
self.location_manager.free[1] : 'carda',
self.location_manager.free[2] : 'cardb' }
on_card = space.get(sorted(space.keys(), reverse=True)[0], None)
try:
total_size = sum([os.stat(f).st_size for f in files])
except:
try:
traceback.print_exc()
except:
pass
total_size = self.location_manager.free[0]
if self.location_manager.free[0] > total_size + (1024**2):
# Send news to main memory if enough space available
on_card = None
self.upload_books(files, names, metadata,
on_card=on_card,
memory=[files, remove])