mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-05-07 09:19:50 +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:
parent
ef8f8f0e44
commit
80f659858c
10
core/app.py
10
core/app.py
@ -148,7 +148,7 @@ class DupeGuru(Broadcaster):
|
|||||||
self.stats_label = StatsLabel(self)
|
self.stats_label = StatsLabel(self)
|
||||||
self.result_table = None
|
self.result_table = None
|
||||||
self.deletion_options = DeletionOptions()
|
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]
|
children = [self.directory_tree, self.stats_label, self.details_panel]
|
||||||
for child in children:
|
for child in children:
|
||||||
child.connect()
|
child.connect()
|
||||||
@ -307,6 +307,14 @@ class DupeGuru(Broadcaster):
|
|||||||
}[jobid]
|
}[jobid]
|
||||||
self.view.show_message(msg)
|
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
|
@staticmethod
|
||||||
def _remove_hardlink_dupes(files):
|
def _remove_hardlink_dupes(files):
|
||||||
seen_inodes = set()
|
seen_inodes = set()
|
||||||
|
@ -222,10 +222,7 @@ class Results(Markable):
|
|||||||
do_match(other_files[0], other_files[1:], group)
|
do_match(other_files[0], other_files[1:], group)
|
||||||
|
|
||||||
self.apply_filter(None)
|
self.apply_filter(None)
|
||||||
try:
|
root = ET.parse(infile).getroot()
|
||||||
root = ET.parse(infile).getroot()
|
|
||||||
except Exception:
|
|
||||||
return
|
|
||||||
group_elems = list(root.getiterator('group'))
|
group_elems = list(root.getiterator('group'))
|
||||||
groups = []
|
groups = []
|
||||||
marked = set()
|
marked = set()
|
||||||
|
@ -9,6 +9,7 @@ import os.path as op
|
|||||||
|
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
|
|
||||||
|
from pytest import raises
|
||||||
from hscommon.testutil import eq_
|
from hscommon.testutil import eq_
|
||||||
from hscommon.util import first
|
from hscommon.util import first
|
||||||
|
|
||||||
@ -614,16 +615,15 @@ class TestCaseResultsXML:
|
|||||||
f.seek(0)
|
f.seek(0)
|
||||||
app = DupeGuru()
|
app = DupeGuru()
|
||||||
r = Results(app)
|
r = Results(app)
|
||||||
r.load_from_xml(f, None)
|
with raises(ET.ParseError):
|
||||||
|
r.load_from_xml(f, None)
|
||||||
eq_(0, len(r.groups))
|
eq_(0, len(r.groups))
|
||||||
|
|
||||||
def test_load_non_existant_xml(self):
|
def test_load_non_existant_xml(self):
|
||||||
app = DupeGuru()
|
app = DupeGuru()
|
||||||
r = Results(app)
|
r = Results(app)
|
||||||
try:
|
with raises(IOError):
|
||||||
r.load_from_xml('does_not_exist.xml', None)
|
r.load_from_xml('does_not_exist.xml', None)
|
||||||
except IOError:
|
|
||||||
self.fail()
|
|
||||||
eq_(0, len(r.groups))
|
eq_(0, len(r.groups))
|
||||||
|
|
||||||
def test_remember_match_percentage(self):
|
def test_remember_match_percentage(self):
|
||||||
|
2
hscommon
2
hscommon
@ -1 +1 @@
|
|||||||
Subproject commit 316af1bca53915f99b9bb874064cba6bee881cc1
|
Subproject commit fd90d2e601752b9bf9cdd32bb6b7613fa05ec097
|
Loading…
x
Reference in New Issue
Block a user