[#78 state:fixed] Wrapped appscript errors, updated error message and the F.A.Q. to give users a clue of what to do.

--HG--
extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40257
This commit is contained in:
hsoft 2009-12-15 16:23:02 +00:00
parent b487189742
commit c9b0a278ca
3 changed files with 36 additions and 12 deletions

View File

@ -403,7 +403,11 @@ http://www.hardcoded.net/licenses/hs_license
if ([lastAction isEqualTo:jobDelete])
{
if (r > 0)
[Dialogs showMessage:[NSString stringWithFormat:@"%d file(s) couldn't be sent to Trash. They were kept in the results, and still are marked.",r]];
{
NSString *msg = @"%d file(s) couldn't be sent to Trash. They were kept in the results, "\
"and still are marked. See the F.A.Q. section in the help file for details.";
[Dialogs showMessage:[NSString stringWithFormat:msg,r]];
}
else
[Dialogs showMessage:@"All marked files were sucessfully sent to Trash."];
}

View File

@ -61,4 +61,14 @@ Enable the [Power Marker](power_marker.htm) mode and click on the Directory colu
* **Windows**: Click on **Actions --> Apply Filter**, then type "copy", then click OK.
* **Mac OS X**: Type "copy" in the "Filter" field in the toolbar.
* Click on **Mark --> Mark All**.
### I tried to send my duplicates to Trash, but dupeGuru is telling me it can't do it. Why? What can I do?
Most of the time, the reason why dupeGuru can't send files to Trash is because of file permissions. You need *write* permissions on files you want to send to Trash. If you're not familiar with the command line, you can use utilities such as [BatChmod](http://macchampion.com/arbysoft/BatchMod) to fix your permissions.
If dupeGuru still gives you troubles after fixing your permissions, there have been some cases where using "Move Marked to..." as a workaround did the trick. So instead of sending your files to Trash, you send them to a temporary folder with the "Move Marked to..." action, and then you delete that temporary folder manually.
If you're trying to delete *iPhoto* pictures, then the reason for the failure is different. The deletion fails because dupeGuru can't communicate with iPhoto. Be aware that for the deletion to work correctly, you're not supposed to play around iPhoto while dupeGuru is working. Also, sometimes, the Applescript system doesn't seem to know where to find iPhoto to launch it. It might help in these cases to launch iPhoto *before* you send your duplicates to Trash.
If all of this fail, [contact HS support](http://www.hardcoded.net/support), we'll figure it out.
</%text>

View File

@ -14,7 +14,7 @@ import re
from Foundation import *
from AppKit import *
from appscript import app, k
from appscript import app, k, CommandError
from hsutil import io
from hsutil.str import get_file_ext
@ -142,12 +142,18 @@ class DupeGuruPE(app_cocoa.DupeGuru):
self.path2iphoto = {}
if any(isinstance(dupe, IPhoto) for dupe in marked):
j = j.start_subjob([6, 4], "Probing iPhoto. Don\'t touch it during the operation!")
a = app('iPhoto')
a.activate(timeout=0)
a.select(a.photo_library_album(timeout=0), timeout=0)
photos = as_fetch(a.photo_library_album().photos, k.item)
for photo in j.iter_with_progress(photos):
self.path2iphoto[unicode(photo.image_path(timeout=0))] = photo
try:
a = app('iPhoto')
a.activate(timeout=0)
a.select(a.photo_library_album(timeout=0), timeout=0)
photos = as_fetch(a.photo_library_album().photos, k.item)
for photo in j.iter_with_progress(photos):
try:
self.path2iphoto[unicode(photo.image_path(timeout=0))] = photo
except CommandError:
pass
except (CommandError, RuntimeError):
pass
j.start_job(self.results.mark_count, "Sending dupes to the Trash")
self.last_op_error_count = self.results.perform_on_marked(op, True)
del self.path2iphoto
@ -156,11 +162,15 @@ class DupeGuruPE(app_cocoa.DupeGuru):
if isinstance(dupe, IPhoto):
if unicode(dupe.path) in self.path2iphoto:
photo = self.path2iphoto[unicode(dupe.path)]
a = app('iPhoto')
a.remove(photo, timeout=0)
return True
try:
a = app('iPhoto')
a.remove(photo, timeout=0)
return True
except (CommandError, RuntimeError):
return False
else:
logging.warning("Could not find photo {0} in iPhoto Library", unicode(dupe.path))
logging.warning(u"Could not find photo %s in iPhoto Library", unicode(dupe.path))
return False
else:
return app_cocoa.DupeGuru._do_delete_dupe(self, dupe)