1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-12-06 12:49:02 +00:00

Fail with excplicit message when unable to load results file

Previously, we would simply show an empty results window. Not very
helpful.
This commit is contained in:
Virgil Dupras 2016-06-07 21:34:04 -04:00
parent ef8f8f0e44
commit 80f659858c
4 changed files with 15 additions and 10 deletions

View File

@ -148,7 +148,7 @@ class DupeGuru(Broadcaster):
self.stats_label = StatsLabel(self)
self.result_table = None
self.deletion_options = DeletionOptions()
self.progress_window = ProgressWindow(self._job_completed)
self.progress_window = ProgressWindow(self._job_completed, self._job_error)
children = [self.directory_tree, self.stats_label, self.details_panel]
for child in children:
child.connect()
@ -307,6 +307,14 @@ class DupeGuru(Broadcaster):
}[jobid]
self.view.show_message(msg)
def _job_error(self, jobid, err):
if jobid == JobType.Load:
msg = tr("Could not load file: {}").format(err)
self.view.show_message(msg)
return False
else:
raise err
@staticmethod
def _remove_hardlink_dupes(files):
seen_inodes = set()

View File

@ -222,10 +222,7 @@ class Results(Markable):
do_match(other_files[0], other_files[1:], group)
self.apply_filter(None)
try:
root = ET.parse(infile).getroot()
except Exception:
return
root = ET.parse(infile).getroot()
group_elems = list(root.getiterator('group'))
groups = []
marked = set()

View File

@ -9,6 +9,7 @@ import os.path as op
from xml.etree import ElementTree as ET
from pytest import raises
from hscommon.testutil import eq_
from hscommon.util import first
@ -614,16 +615,15 @@ class TestCaseResultsXML:
f.seek(0)
app = DupeGuru()
r = Results(app)
r.load_from_xml(f, None)
with raises(ET.ParseError):
r.load_from_xml(f, None)
eq_(0, len(r.groups))
def test_load_non_existant_xml(self):
app = DupeGuru()
r = Results(app)
try:
with raises(IOError):
r.load_from_xml('does_not_exist.xml', None)
except IOError:
self.fail()
eq_(0, len(r.groups))
def test_remember_match_percentage(self):

@ -1 +1 @@
Subproject commit 316af1bca53915f99b9bb874064cba6bee881cc1
Subproject commit fd90d2e601752b9bf9cdd32bb6b7613fa05ec097