Thursday, July 19, 2018

#1 2010-07-05 09:27:20 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Bug with 'duplicate' on remote file?

I'm testing a script which at some point performs this action:

Applescript:

set theCopy to duplicate theFile
set label index of theCopy to 7

This works fine when theFile is in my home folder. When it is on another Mac (as intended) I get error -10006, and the label cannot be set.
Event history gives me this:

Applescript:

duplicate alias "anderen:Documents:Testfolder:20090513 ERIK REED-Hendriks Bouwbedrijf.txt"
       --> document file "20090513 ERIK REED-Hendriks Bouwbedrijf kopie.txt"
       --> error number 0
   set label index of document file "20090513 ERIK REED-Hendriks Bouwbedrijf kopie.txt" to 7
       --> error number -1728 from document file "20090513 ERIK REED-Hendriks Bouwbedrijf kopie.txt"

Finder dictionary claims 'duplicate' returns a specifier.
But 'document file "20090513 ERIK REED-Hendriks Bouwbedrijf kopie.txt"' doesn't look like a specifier to me.

This is the same event history when working with a local folder:

Applescript:

duplicate alias "Santanni:Users:thijs:Documents:@ Projects:Verbeeld:Testfolder:20090907 KEES REED-Alpro Soja Nederland.txt"
       --> document file "20090907 KEES REED-Alpro Soja Nederland kopie.txt" of folder "Testfolder" of folder "Verbeeld" of folder "@ Projects" of folder "Documents" of folder "thijs" of folder "Users" of startup disk
       --> error number 0
   set label index of document file "20090907 KEES REED-Alpro Soja Nederland kopie.txt" of folder "Testfolder" of folder "Verbeeld" of folder "@ Projects" of folder "Documents" of folder "thijs" of folder "Users" of startup disk to 7
       --> 7

Here I get a specifier. Is this a bug, or have I overlooked something?
And why does the reported error change from -1728 to -10006??

Offline

 

#2 2010-07-05 09:39:44 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11499
Website

Re: Bug with 'duplicate' on remote file?

Hi,

avoid always alias specifiers while sending Apple Remote Events. Use Finder file specifiers instead


regards

Stefan

Offline

 

#3 2010-07-05 01:56:49 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

Hi Stefan,
I'm entering terra incognita now...

Remote events:
Never used them knowingly. Am I using them now? The script does not talk to the remote Finder to do the copy.
'anderen' is mounted on my desktop as a volume (but that may just be a mirage ; ).
All other actions of the script run without problems. This includes creating and writing a new file; opening, reading, changing, saving existing file (incl. changing its label).
'duplicate' duplicates, but does not return a usable specifier, so changing the label of the duplicate fails.

File specifier:
I figured you're talking about this form:
document file "20090907 KEES REED-Alpro Soja Nederland kopie.txt" of folder "Testfolder" of folder .....

'theFile' is returned from 'choose file', so it's an alias.
I found I can coerce this to a file specifier with 'set theFile to file theFile'.
Now I'll just have to see which other part of my script that will break.
Might be safest to use a separate var to take the file specifier, and give that to 'duplicate', hmmm?

And while this may make the problem go away I would still like to understand the cause. That would help big time in avoiding making the same mistake again..

Regards,
Thijs

Offline

 

#4 2010-07-05 02:05:32 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11499
Website

Re: Bug with 'duplicate' on remote file?

sorry for the confusion, while reading "remote file" I assumed you use Apple Remote Events.
Just forget it.
The same rule applies to shared volumes: Avoid alias specifier

Try this

Applescript:


set theFile to (choose file) as text
tell application "Finder"
   set theCopy to duplicate file theFile
   set label index of theCopy to 7
end tell

Last edited by StefanK (2010-07-05 02:06:25 pm)


regards

Stefan

Offline

 

#5 2010-07-05 02:12:24 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

Sorry for creating the confusion!

And solution refreshingly simple.
Thanks.

Offline

 

#6 2010-07-05 02:25:03 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11499
Website

Re: Bug with 'duplicate' on remote file?

You're welcome.

I'm looking forward to the world cup final Netherlands vs. Germany smile
Although I'm german the Dutch deserve their first star

Last edited by StefanK (2010-07-05 02:27:47 pm)


regards

Stefan

Offline

 

#7 2010-07-05 02:43:59 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

Yes, it could happen.
But maybe the dutch team will fear l'histoire qui se repète...
I should hope not.

(It appears Kaapstad is already turning orange. Poor Urugay.)

Offline

 

#8 2010-07-05 02:54:53 pm

McUsr
Member
From:: Southern Norway
Registered: 2010-04-07
Posts: 1776

Re: Bug with 'duplicate' on remote file?

Hello

@Thread: Thanks for great information Stefan.

@Football: Whatever as long as it isn't in favor of Juventus! smile


Best Regards and good Match

McUsr

Last edited by McUsr (2010-07-05 02:56:01 pm)


Mercurial vcs is a joy to use for scripting.


Filed under: files remote disks

Offline

 

#9 2010-07-05 02:59:35 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11499
Website

Re: Bug with 'duplicate' on remote file?

McUsr wrote:

@Football: Whatever as long as it isn't in favor of Juventus! smile


Torino? Italy is licking it's wounds wink


regards

Stefan

Offline

 

#10 2010-07-05 05:31:39 pm

McUsr
Member
From:: Southern Norway
Registered: 2010-04-07
Posts: 1776

Re: Bug with 'duplicate' on remote file?

Hello
big_smile I have no grudge against Italy. smile Only Juventus smile

Best Regards

McUsr


Mercurial vcs is a joy to use for scripting.


Filed under: Football

Offline

 

#11 2010-07-07 08:02:10 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

Well, this does not work:

Applescript:

set theFile to (choose file) as text
tell application "Finder"
   set theCopy to duplicate file theFile
   set label index of theCopy to 7
end tell

Like before, it duplicates, but theCopy is not a valid specifier.

I thought of putting the second line in a try block, build the path for theCopy in the error handler, then set the label there.
But I can get absolutely nothing from the return value of 'duplicate' - it has no class...:/
Saying 'theCopy as <anything>' just gives another error.

I have the path string for the original file, so I could make a path string for the copy from that.
Will work (knock wood) but feels crummy. Sigh.

Offline

 

#12 2010-07-07 09:06:24 am

McUsr
Member
From:: Southern Norway
Registered: 2010-04-07
Posts: 1776

Re: Bug with 'duplicate' on remote file?

Hello

Could you please show us the error message from an on error e number n statement within a try end try clause?

Best Regards

McUsr


Mercurial vcs is a joy to use for scripting.


Filed under: Finder, duplicate file

Offline

 

#13 2010-07-07 09:47:53 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

That error & number are shown in the first post.
You can also see that "duplicate" is successful (error 0), but does not return a valid specifier.

Error Codes says:
"-1728: errAENoSuchObject - e.g.,: specifier asked for the 3rd, but there are only 2."

Yes, obviously. It's not a full path.


I'm stumped.

Offline

 

#14 2010-07-07 11:26:17 am

McUsr
Member
From:: Southern Norway
Registered: 2010-04-07
Posts: 1776

Re: Bug with 'duplicate' on remote file?

Hello.

Have you tried to circumvent the problem by creating a reference to the file after it is duplicated?

Besides that: Script Debugger's dictionary says it returns a reference, that might imply that you should try using the contents of that reference as a specifier. But I haven't tested it.



Best Regards

McUsr


Mercurial vcs is a joy to use for scripting.


Filed under: duplicate file

Offline

 

#15 2010-07-07 12:19:19 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

Applescript:

-- local file:
duplicate file "Santanni:Users:thijs:Documents:@ Projects:Verbeeld:Testfolder:20090907 KEES REED-Alpro Soja Nederland.txt"
--> document file "20090907 KEES REED-Alpro Soja Nederland kopie.txt" of folder "Testfolder" of folder "Verbeeld" of folder "@ Projects" of folder "Documents" of folder "thijs" of folder "Users" of startup disk
-- this is a valid specifier

-- remote file:
duplicate file "anderen:Documents:Testfolder:20090513 ERIK REED-Hendriks Bouwbedrijf.txt"
--> document file "20090513 ERIK REED-Hendriks Bouwbedrijf kopie.txt"
-- this only looks like a specifier
-- use or manipulate it in whatever way, and you get an error

This is the workaround I'm going to try:

Applescript:

set theFile to (choose file)
tell application "Finder"
   set theCopy to duplicate file theFile
   try
       set label index of theCopy to 7 -- did it work? Fine!
   on error -- else take the long road
       set theContainer to container of theFile as alias as string
       set theCopyName to displayed name of theFile & " kopie.txt" -- localised
       set theCopy to (theContainer & theCopyName) as alias-- it already exists, no worries
       set label index of theCopy to 7
   end try
end tell

-- Actually the script already knows the container; it's a script global
-- So don't need that 1st line in the error handler
-- And: the script creates the files itself, with extension hidden

This what you had in mind?
[There's a very small possibility that the problem is caused by some activity in the remote account. Checking that too]

Model: iMacs 20" (mid 2007 & mid 2009)
Operating System: Mac OS X (10.6)

Offline

 

#16 2010-07-07 12:25:23 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11499
Website

Re: Bug with 'duplicate' on remote file?

alastor933 wrote:

Applescript:

-
-- remote file:
duplicate file "anderen:Documents:Testfolder:20090513 ERIK REED-Hendriks Bouwbedrijf.txt"
--> document file "20090513 ERIK REED-Hendriks Bouwbedrijf kopie.txt"
-- this only looks like a specifier
-- use or manipulate it in whatever way, and you get an error


Is "anderen" the name of the shared volume? Is the path valid anyway?


regards

Stefan

Offline

 

#17 2010-07-07 12:37:42 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

"'anderen" is a user on the other Mac, mounted as a volume on my desktop. All actions of the script work fine, except setting the label on a duplicated file, because of the faulty specifier that is returned from the "duplicate" command.

This includes creating and writing a new file; opening, reading, changing, saving existing file (incl. changing its label).


Yes, the path is valid, as the file is duplicated.

Last edited by alastor933 (2010-07-07 12:40:17 pm)

Offline

 

#18 2010-07-07 12:59:37 pm

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

I think I have the beginning of an explanation.
It's voodoo big_smile

Well....
I was almost sure I'd seen a grey-labeled copy materialise some time yesterday.
Then, when I continued this afternoon, it failed again.
Just now, it worked.

The difference?
This afternoon our youngest was playing WarCraft III in that "anderen" account.
Right now, and yesterday, he was not.

I'm not exactly WoWed by this finding roll
I'll do a more rigorous test later.

[edit]
No, that wasn't it. It worked, then didn't work, then worked, then not.
[/edit]

Last edited by alastor933 (2010-07-07 01:35:48 pm)

Offline

 

#19 2010-07-07 01:39:02 pm

McUsr
Member
From:: Southern Norway
Registered: 2010-04-07
Posts: 1776

Re: Bug with 'duplicate' on remote file?

Hello

I find it odd if it works when nobody are logged in, but don't work when somebody is logged in.
It may be logical, but not by intuition!


Best Regards

McUsr


Mercurial vcs is a joy to use for scripting.


Filed under: Finder, duplicate file

Offline

 

#20 2010-07-08 05:41:43 am

alastor933
Member
From:: Utrecht, NL
Registered: 2008-09-12
Posts: 545

Re: Bug with 'duplicate' on remote file?

Somebody else bumped into this bug as well.

So it's the workaround.

@McUsr:
I didn't say nobody was logged in, just that nobody was playing WarCraft III.
But I got curious: it appears that you can logout, and back into another account, then log out again, without breaking an existing connection. Last time I checked the remote Mac nobody was logged in. When I asked around my wife said she had been working in her own account - so she had logged out of "anderen" and into her own account.

And all the time  "anderen" was mounted on my desktop, and I didn't notice anything.

Last edited by alastor933 (2010-07-08 05:58:43 am)

Offline

 

#21 2010-07-08 07:04:44 am

McUsr
Member
From:: Southern Norway
Registered: 2010-04-07
Posts: 1776

Re: Bug with 'duplicate' on remote file?

Hello

Thank you very much for the link.
It is nice to figure out what goes wrong.


Best Regards

McUsr


Mercurial vcs is a joy to use for scripting.


Filed under: Mounted drives.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)