From 7c635ce79b72c455e643a4ea036f68577faeb62d Mon Sep 17 00:00:00 2001 From: phill-ridout Date: Tue, 19 Feb 2013 19:03:50 +0000 Subject: [PATCH] Fixes #1114457 by counting the records --- openlp/plugins/songs/lib/ewimport.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index 8a344c189..06f062e90 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -107,10 +107,6 @@ class EasyWorshipSongImport(SongImport): self.encoding = retrieve_windows_encoding(self.encoding) if not self.encoding: return - # There does not appear to be a _reliable_ way of getting the number - # of songs/records, so let's use file blocks for measuring progress. - total_blocks = (db_size - header_size) / (block_size * 1024) - self.importWizard.progressBar.setMaximum(total_blocks) # Read the field description information db_file.seek(120) field_info = db_file.read(num_fields * 2) @@ -134,12 +130,22 @@ class EasyWorshipSongImport(SongImport): except IndexError: # This is the wrong table success = False - # Loop through each block of the file + # There does not appear to be a _reliable_ way of getting the number of songs/records, so loop through the file + # blocks and total the number of records. Store the information in a list so we dont have to do all this again. cur_block = first_block + total_count = 0 + block_list = [] while cur_block != 0 and success: - db_file.seek(header_size + ((cur_block - 1) * 1024 * block_size)) + cur_block_pos = header_size + ((cur_block - 1) * 1024 * block_size) + db_file.seek(cur_block_pos) cur_block, rec_count = struct.unpack('