Permalink
Browse files

Device sync: Only fail if we can determine free disk space (bug 2052)

  • Loading branch information...
1 parent db7d9bc commit 169102de09d853181a73a8218a6d5c55f74e34d7 @thp thp committed Dec 16, 2015
Showing with 11 additions and 5 deletions.
  1. +1 −1 src/gpodder/opml.py
  2. +8 −2 src/gpodder/sync.py
  3. +2 −2 src/gpodder/util.py
View
@@ -179,7 +179,7 @@ def write( self, channels):
FREE_DISK_SPACE_AFTER = 1024*512
path = os.path.dirname(self.filename) or os.path.curdir
available = util.get_free_disk_space(path)
- if available < 2*len(data)+FREE_DISK_SPACE_AFTER:
+ if available != -1 and available < 2*len(data)+FREE_DISK_SPACE_AFTER:
# On Windows, if we have zero bytes available, assume that we have
# not had the win32file module available + assume enough free space
if not gpodder.ui.win32 or available > 0:
View
@@ -281,7 +281,11 @@ def __init__(self, config,
def get_free_space(self):
# Reserve 10 MiB for iTunesDB writing (to be on the safe side)
RESERVED_FOR_ITDB = 1024*1024*10
- return util.get_free_disk_space(self.mountpoint) - RESERVED_FOR_ITDB
+ result = util.get_free_disk_space(self.mountpoint)
+ if result == -1:
+ # Can't get free disk space
+ return -1
+ return result - RESERVED_FOR_ITDB
def open(self):
Device.open(self)
@@ -565,7 +569,9 @@ def add_track(self, episode,reporthook=None):
# verify free space
needed = util.calculate_size(from_file)
free = self.get_free_space()
- if needed > free:
+ if free == -1:
+ logger.warn('Cannot determine free disk space on device')
+ elif needed > free:
d = {'path': self.destination, 'free': util.format_filesize(free), 'need': util.format_filesize(needed)}
message =_('Not enough space in %(path)s: %(free)s available, but need at least %(need)s')
raise SyncFailedException(message % d)
View
@@ -453,7 +453,7 @@ def get_free_disk_space_win32(path):
"""
if win32file is None:
# Cannot determine free disk space
- return 0
+ return -1
drive, tail = os.path.splitdrive(path)
userFree, userTotal, freeOnDisk = win32file.GetDiskFreeSpaceEx(drive)
@@ -470,7 +470,7 @@ def get_free_disk_space(path):
"""
if not os.path.exists(path):
- return 0
+ return -1
if gpodder.ui.win32:
return get_free_disk_space_win32(path)

0 comments on commit 169102d

Please sign in to comment.