Closed Bug 394821 Opened 17 years ago Closed 16 years ago

Moving a bookmark to a folder via AppleScript deletes the folder (and contents)

Categories

(Camino Graveyard :: OS Integration, defect)

PowerPC
macOS
defect
Not set
major

Tracking

(Not tracked)

RESOLVED FIXED
Camino1.6

People

(Reporter: alqahira, Assigned: peeja)

References

Details

(Keywords: fixed1.8.1.13)

Attachments

(2 files, 3 obsolete files)

The script

tell application "Camino"
    move bookmark "Test" of bookmark bar collection to ¬
        bookmark folder "Test ƒ" of bookmark bar collection
end tell

deletes "Test ƒ" (and any of its contents) instead of moving "Test" into the folder ("Test" remains in the bar).
FWIW, it actually moved the bookmark "Test" to after the last bookmark, if the folder "Test ƒ" was situated among bookmarks.
Taking.  No idea why this is happening, but I'll figure it out.
Assignee: nobody → peter.a.jaros
Blocks: 382493
Ah, this script is working correctly.  The script that does what you meant would be this:

tell application "Camino"
    move bookmark "Test" of bookmark bar collection to ¬
        end of bookmark items of bookmark folder "Test ƒ" of bookmark bar collection
end tell

Not so great that what you wrote isn't right; worse that it results in data loss.  It's on the agenda for the Oct. 24th meeting.
Not blocking a1, but peeja has an idea how to fix this that he's going to investigate.
Flags: camino1.6a1?
Flags: camino1.6a1-
Flags: camino1.6?
Peter, any work on this?
Nothing new yet, but the semester's over now.  I'm getting back to the AppleScript stuff now, though my first task is getting a tree to build again.
Got it.  This patch adds a new MoveCommand handler for the move command.  If it's called on to replace something ("move X to Y"), it will alter its arguments to mean "move X to the end of Y".  If Y is not a collection, the script errors, which makes sense.  Other insertion positions, such as "move X to before Y", work as before.

Project patches for trunk and branch are provided separately.
Attachment #300891 - Flags: review?(murph)
Attached patch Trunk Project Patch (obsolete) — Splinter Review
Attachment #300892 - Flags: review?(murph)
Attached patch Branch Project Patch (obsolete) — Splinter Review
Attachment #300894 - Flags: review?(murph)
Comment on attachment 300891 [details] [diff] [review]
MoveCommand(.mm|.h) + Camino.sdef change

Behavior works as expected; with the one code change below, r=murph.

>+  NSMutableDictionary *args = [[self arguments] mutableCopy];

Using |mutableCopy| means you'll have to release |args| after calling |setArguments:|.  I'd either tack on an |autorelease| or just use [NSMutableDictionary dictionaryWithDictionary:].
Attachment #300891 - Flags: review?(murph) → review+
Comment on attachment 300892 [details] [diff] [review]
Trunk Project Patch

Unfortunately, the project file changed in the last few days, breaking this patch already.  You'll need to re-diff :)
Attachment #300892 - Flags: review?(murph) → review-
Comment on attachment 300894 [details] [diff] [review]
Branch Project Patch

Cancelling the review request on this, since it's likely bitrotted and we need a new code patch anyway.
Attachment #300894 - Flags: review?(murph)
Comment on attachment 300894 [details] [diff] [review]
Branch Project Patch

Cancelling the review request on this, since it's likely bitrotted and we need a new code patch anyway.
Plussing/targeting 1.6 since this is dataloss and the patch is close.  

Can we get an ETA on a new version?
Flags: camino1.6? → camino1.6+
Target Milestone: --- → Camino1.6
I'll be as soon as I can get a tree building, so probably by tonight. If I can't get it going by tonight, I'll try to get someone else to spin the patch for me.
Attached patch Code respinSplinter Review
+ murph's change.
Attachment #300891 - Attachment is obsolete: true
Attachment #303176 - Flags: superreview?(stuart.morgan)
Again, just adds MoveCommand.*.  Probably needs a port to branch, which Smokey offered to do on checkin.
Attachment #300892 - Attachment is obsolete: true
Attachment #300894 - Attachment is obsolete: true
Attachment #303180 - Flags: superreview?(stuart.morgan)
Comment on attachment 303176 [details] [diff] [review]
Code respin

>Index: src/appleevents/MoveCommand.h
>+ * Portions created by the Initial Developer are Copyright (C) 2007

>Index: src/appleevents/MoveCommand.mm
>+ * Portions created by the Initial Developer are Copyright (C) 2007

Er, make that 2008, would you?  I swear I've gotten it right on all my checks...
Comment on attachment 303176 [details] [diff] [review]
Code respin

>+    NSPositionalSpecifier *newToLoc = [[NSPositionalSpecifier alloc] initWithPosition:NSPositionBeginning objectSpecifier:[toLoc objectSpecifier]];

Three things here:
- Why is this NSPositionBeginning, when the discussion was about putting it at the end (which seems more likely to be the expected behavior)?
- The specificier is leaked, and should be autoreleased on this line.
- The line is really long, and should be broken before |objectSpecifier|
Attachment #303176 - Flags: superreview?(stuart.morgan) → superreview-
Comment on attachment 303180 [details] [diff] [review]
Trunk Proj. Patch, clean of bitrot

(No need for separate review of project bits)
Attachment #303180 - Flags: superreview?(stuart.morgan)
(In reply to comment #19)
> (From update of attachment 303176 [details] [diff] [review])
> >+    NSPositionalSpecifier *newToLoc = [[NSPositionalSpecifier alloc] initWithPosition:NSPositionBeginning objectSpecifier:[toLoc objectSpecifier]];
> 
> Three things here:
> - Why is this NSPositionBeginning, when the discussion was about putting it at
> the end (which seems more likely to be the expected behavior)?

Yes, this was supposed to be NSPositionEnd, but I used NSPositionBeginning first and somehow I diffed from that version.  Sorry I haven't been able to spin a new patch yet.  If you can make the the changes on checkin, Stuart, that would be awesome.
Landed on trunk and MOZILLA_1_8_BRANCH with the comment 19 fixes.
Status: NEW → RESOLVED
Closed: 16 years ago
Keywords: datalossfixed1.8.1.13
Resolution: --- → FIXED
I checked in an additional fix for comment 18.  Farewell bookmark-eating AppleScripts!

One of us needs to update the AppleScript Guide about this.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: