From 806f6d742535988a805e206c03722173aff5eb88 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Feb 2011 16:11:51 -0700 Subject: [PATCH] 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) --- src/calibre/gui2/device.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 8efa7f154c..735eb7782b 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -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])