File moving too early

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

Moderator: Mr_Noodle

File moving too early Thu Apr 27, 2017 7:12 am • by timmeh
Hi All,

Long time Hazel user, never realised this forum was here!!

I wonder if anyone else has found a way around an issue I have...

I'm using UltraCopier to copy a massive amount of files from an offsite NAS to the Box I have running Hazel. Once the copy is complete I was hoping to have Hazel copy the file elsewhere to be processed etc. The problem I am having is because UltraCopier does not "lock" the file whilst it is being copied, Hazel is able to relocate it as soon as it is created, causing a really small file to be sent through the rest of the processing.

Does anyone have a method of stopping Hazel from touching files until something totally external like UltraCopier has finished with it? I dare say rsync may create the same issue, as might cp. (I haven't tested these, but I would assume they would be similar)

Thanks!
timmeh
 
Posts: 1
Joined: Thu Apr 27, 2017 7:08 am

Re: File moving too early Thu Apr 27, 2017 10:41 am • by Mr_Noodle
If the program doesn't lock it then you'll probably have to resort to adding a delay to Hazel. You can try something like "Date modified is not in the last X minutes". You'll have to play with the time needed.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: File moving too early Wed May 03, 2017 6:53 pm • by ozdan
I've used this as a shell script that must be passed as a condition before running the actions:

# Get disk usage of file, touch first to update
touch -c """$1""";
filesize_pass01=$(du -k """$1""" | cut -d'.' -f 1 | bc)

# Pause for filesize to grow while copy still progressing, set the delay in seconds as you see fit
sleep 3

# Get disk usage after time has passed to see if it has grown, touch first to update
touch -c """$1"""
filesize_pass02=$(du -k """$1""" | cut -d'.' -f 1 | bc)

isNotZeroFilesize=$(echo "$filesize_pass01 > 1000" | bc)
isFinishedWriting=$(echo "$filesize_pass01 == $filesize_pass02" | bc)
if [ $isNotZeroFilesize == 1 ]; then
if [ $isFinishedWriting == 1 ]; then
exit 0
fi
fi

Hope this helps or points in the right direction.

Dan

timmeh wrote:Hi All,

Long time Hazel user, never realised this forum was here!!

I wonder if anyone else has found a way around an issue I have...

I'm using UltraCopier to copy a massive amount of files from an offsite NAS to the Box I have running Hazel. Once the copy is complete I was hoping to have Hazel copy the file elsewhere to be processed etc. The problem I am having is because UltraCopier does not "lock" the file whilst it is being copied, Hazel is able to relocate it as soon as it is created, causing a really small file to be sent through the rest of the processing.

Does anyone have a method of stopping Hazel from touching files until something totally external like UltraCopier has finished with it? I dare say rsync may create the same issue, as might cp. (I haven't tested these, but I would assume they would be similar)

Thanks!
ozdan
 
Posts: 1
Joined: Wed May 03, 2017 6:39 pm


Return to Support