Folder Action: A workflow attached to a folder in the Finder. When items are added to the folder, the workflow runs and the files are used as input to the workflow.
- Camera Uploads! organizer (Dropbox folder) Service Automator Workflow Folder Actions
- Dropbox-Mover-J.workflow (Folder Action)
- Folder Organizer! MISC …
- iCloud-Drive-Mover-J.workflow (Folder Action)
- Move Items to Downloads
- Screenshot! Screenshots! Screen shot – filename-Cleanup – services
Contents
Problems
“Resource deadlock avoided”
Problem, Research
Brave: folder actions, cloud-based storage, file not downloaded, ‘Resource deadlock avoided’
Google: folder actions, cloud-based storage, file not downloaded, ‘Resource deadlock avoided’
The below is from Brave:
The “Resource deadlock avoided” error on macOS typically occurs when software (such as Folder Actions, Hazel, or backup utilities) attempts to access files in cloud-based storage folders (like OneDrive, iCloud, or Box) that are currently not downloaded to the local machine. This happens because modern cloud clients use a “Files on Demand” system where file metadata exists locally, but the actual data blocks are stored in the cloud and only downloaded when accessed.
If a process tries to read or move a file that hasn’t been materialized locally, or if it lacks proper file coordination APIs (like NSFileCoordinator), the system prevents the operation to avoid a deadlock, resulting in this error.
Solutions and Workarounds:
-
Download Files Locally: Ensure the specific files or folders are set to “Always Keep on This Device” (or “Available Offline”) so they are physically present on the hard drive.
-
Use File Coordination APIs: For developers or app creators, wrapping file access in
NSFileCoordinatorensures the system properly triggers the download before the read operation. -
Exclude Cloud Folders: If the software is a backup tool, exclude the
~/Library/CloudStorage/directory from the scan, as these files are virtual placeholders. -
Reset Cloud Client: In cases of syncing corruption, resetting the cloud application (e.g., OneDrive’s
ResetOneDriveAppStandalone.command) can resolve persistent access issues.
Solution(s)
Still working on generic, reliable, solution. For files that requires CONTENT. I.e.
- NOT a problem: files that are only MOVED around, e.g. camera files being organized into folders works fine, as it’s only the “file reference” that is moved. (Doesn’t care about file content.)
- IS a problem: files that one wants to use content of, e.g. retrieve media-internal meta data for processing in a Folder Action. Then the Folder Action code MUST ensure file really is fully downloaded locally before any more processing is done, OR one WILL get Resource deadlock problems.
Time to execute…. (follows Resource… above, for cloud-based items)
Problem with any on-demand forcing downloading files from cloud-based storage before further processing in scripts can end up taking lots of time. Think case of moving a folder with media and each media [file] needs contents.
- Bigger files maybe end up taking seconds to tens of seconds or even more if involve video files,
- I.e. processing may end up seemingly being hanging.
- ONE needs carefully considering time aspects and possibly
- include warning dialog ahead of process start
- include progress notifications
EoP