1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-11-04 15:29:02 +00:00

Removed the "all files are refs" error message and made the "no files, can't scan" message quicker. That's because when scanning iPhoto libraries with big libraries, the GUI would hang because these checks would involve loading the whole library.

This commit is contained in:
Virgil Dupras 2010-08-15 15:07:44 +02:00
parent c8827769b4
commit 36eccb7122
8 changed files with 18 additions and 20 deletions

View File

@ -69,8 +69,6 @@ http://www.hardcoded.net/licenses/hs_license
[_py setMixFileKind:[ud objectForKey:@"mixFileKind"]]; [_py setMixFileKind:[ud objectForKey:@"mixFileKind"]];
[_py setMatchSimilarWords:[ud objectForKey:@"matchSimilarWords"]]; [_py setMatchSimilarWords:[ud objectForKey:@"matchSimilarWords"]];
NSInteger r = n2i([py doScan]); NSInteger r = n2i([py doScan]);
if (r == 1)
[Dialogs showMessage:@"You cannot make a duplicate scan with only reference directories."];
if (r == 3) if (r == 3)
{ {
[Dialogs showMessage:@"The selected directories contain no scannable file."]; [Dialogs showMessage:@"The selected directories contain no scannable file."];

View File

@ -65,8 +65,6 @@ http://www.hardcoded.net/licenses/hs_license
int r = n2i([py doScan]); int r = n2i([py doScan]);
if (r != 0) if (r != 0)
[[ProgressController mainProgressController] hide]; [[ProgressController mainProgressController] hide];
if (r == 1)
[Dialogs showMessage:@"You cannot make a duplicate scan with only reference directories."];
if (r == 3) if (r == 3)
{ {
[Dialogs showMessage:@"The selected directories contain no scannable file."]; [Dialogs showMessage:@"The selected directories contain no scannable file."];

View File

@ -59,8 +59,6 @@ http://www.hardcoded.net/licenses/hs_license
int r = n2i([py doScan]); int r = n2i([py doScan]);
if (r != 0) if (r != 0)
[[ProgressController mainProgressController] hide]; [[ProgressController mainProgressController] hide];
if (r == 1)
[Dialogs showMessage:@"You cannot make a duplicate scan with only reference directories."];
if (r == 3) if (r == 3)
{ {
[Dialogs showMessage:@"The selected directories contain no scannable file."]; [Dialogs showMessage:@"The selected directories contain no scannable file."];

View File

@ -33,9 +33,6 @@ JOB_DELETE = 'job_delete'
class NoScannableFileError(Exception): class NoScannableFileError(Exception):
pass pass
class AllFilesAreRefError(Exception):
pass
class DupeGuru(RegistrableApplication, Broadcaster): class DupeGuru(RegistrableApplication, Broadcaster):
DEMO_LIMIT_DESC = "In the demo version, only 10 duplicates per session can be sent to the recycle bin, moved or copied." DEMO_LIMIT_DESC = "In the demo version, only 10 duplicates per session can be sent to the recycle bin, moved or copied."
@ -347,12 +344,8 @@ class DupeGuru(RegistrableApplication, Broadcaster):
logging.info('Scanning %d files' % len(files)) logging.info('Scanning %d files' % len(files))
self.results.groups = self.scanner.GetDupeGroups(files, j) self.results.groups = self.scanner.GetDupeGroups(files, j)
files = self.directories.get_files() if not self.directories.has_any_file():
first_file = first(files)
if first_file is None:
raise NoScannableFileError() raise NoScannableFileError()
if first_file.is_ref and all(f.is_ref for f in files):
raise AllFilesAreRefError()
self.results.groups = [] self.results.groups = []
self._start_job(JOB_SCAN, do) self._start_job(JOB_SCAN, do)

View File

@ -76,6 +76,4 @@ class DupeGuru(app.DupeGuru):
return 0 return 0
except app.NoScannableFileError: except app.NoScannableFileError:
return 3 return 3
except app.AllFilesAreRefError:
return 1

View File

@ -124,6 +124,13 @@ class Directories(object):
else: else:
return STATE_NORMAL return STATE_NORMAL
def has_any_file(self):
try:
next(self.get_files())
return True
except StopIteration:
return False
def load_from_file(self, infile): def load_from_file(self, infile):
try: try:
root = ET.parse(infile).getroot() root = ET.parse(infile).getroot()

View File

@ -122,6 +122,15 @@ class Directories(directories.Directories):
else: else:
directories.Directories.add_path(self, path) directories.Directories.add_path(self, path)
def has_any_file(self):
# If we don't do that, it causes a hangup in the GUI when we click Start Scanning because
# checking if there's any file to scan involves reading the whole library. If we have the
# iPhoto library, we assume we have at least one file.
if any(path == Path('iPhoto Library') for path in self._dirs):
return True
else:
return directories.Directories.has_any_file(self)
class DupeGuruPE(app_cocoa.DupeGuru): class DupeGuruPE(app_cocoa.DupeGuru):
def __init__(self): def __init__(self):

View File

@ -14,7 +14,7 @@ from PyQt4.QtGui import (QMainWindow, QMenu, QPixmap, QIcon, QToolButton, QLabel
from hsutil.misc import nonone from hsutil.misc import nonone
from core.app import NoScannableFileError, AllFilesAreRefError from core.app import NoScannableFileError
from . import dg_rc from . import dg_rc
from .main_window_ui import Ui_MainWindow from .main_window_ui import Ui_MainWindow
@ -271,9 +271,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
msg = "The selected directories contain no scannable file." msg = "The selected directories contain no scannable file."
QMessageBox.warning(self, title, msg) QMessageBox.warning(self, title, msg)
self.app.show_directories() self.app.show_directories()
except AllFilesAreRefError:
msg = "You cannot make a duplicate scan with only reference directories."
QMessageBox.warning(self, title, msg)
def showHelpTriggered(self): def showHelpTriggered(self):
self.app.show_help() self.app.show_help()