Upload / Connect to network server

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Upload / Connect to network server Mon May 24, 2021 9:12 pm • by eyeinhand
I'm sure there's a simple solution to this. My Hazel workflow simply moves files landing in a local folder to one on a network AFP server. As long as the local Mac is connected, all works well. Occasionally, the remote server is rebooted or the network gets reset, and the connection is lost. Reconnecting is simple, but there doesn't seem to be a way to check for that in Hazel.

I have tried adding a step to run a workflow in Automator, which connects fine; but Hazel expects to pass the files from the folder to that first step of "Run Workflow" – not just "connect to server" then perform the rest of the steps in the Hazel workflow with those files – so there's an error.

If I create all the steps in Automator, it will pass the files through as results to the subsequent steps; but that bypasses Hazel altogether. (Hazel has better flow control, or I would just stick with Automator.)

Thanks for suggestions.
eyeinhand
 
Posts: 3
Joined: Mon May 24, 2021 9:02 pm

Re: Upload / Connect to network server Tue May 25, 2021 9:26 am • by Mr_Noodle
I'm not sure if I'm following. Hazel will pass the files but it doesn't care if the workflow actually uses them or not. What's the error you are seeing?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Upload / Connect to network server Tue May 25, 2021 5:39 pm • by eyeinhand
Right. The existing Hazel rules for the watched folder has just two steps:

1. Move the image files to a "done" folder on the local Mac.
2. Copy those same files to a target folder on the share drive of a server on the network.

This works fine as long as the server share remains connected. But often the server connect gets lost for one reason or another.

I have simple Automator workflow that will make the connection to the server. Credentials are saved in the keychain, so those Automator actions are just
Get Specified Server
Connect to Servers
This also works if run as a standalone Automator action.

However, if I add this Automator workflow as the first step in Hazel, it looks like Hazel is trying to pass the files to the Automator workflow as the path and I get this error:

"less than a minute ago : The action “Connect to Servers” encountered an error: “Failed to connect to server “file:///Volumes/RAID-Photo/Photography/Automation/3-WebMaskOnly-2Quad/65K68_PHFA21-133-4512-silo.psd”.”

The correct Get Specified Server action in the workflow is the network address of that share
afp://172.XX.XX.X/TargetFolder

Maybe I need to modify the workflow to Ignore Inputs?
eyeinhand
 
Posts: 3
Joined: Mon May 24, 2021 9:02 pm

Re: Upload / Connect to network server Tue May 25, 2021 6:10 pm • by eyeinhand
OK, well, I found something that works. Automator would mount the server if not connected, but if it was already connected it would fail that step. I need it to check first, mount if needed, and not fail if the connection already exists.

I now have just this AppleScript in that Automator workflow that consists of just a "try" step:

on run {input, parameters}
try
mount volume "afp://172.22.84.7/Quad1"
end try
end run


I tell it to ignore inputs in the Automator step. This seems work. It connects if needed, and doesn't fail if the connection already exists.
eyeinhand
 
Posts: 3
Joined: Mon May 24, 2021 9:02 pm


Return to Support