Locked Files

Discuss RoboTask here
Post Reply
salsaking
Posts: 2
Joined: Wed Oct 18, 2006 7:09 pm

Locked Files

Post by salsaking »

What a great program, it's can do everything i need but... There seems to be a problem when waiting for a locked file.  I need to watch for file changes and adds and if there is one FTP upload the file.  The problem is the files are locked for a while, sometimes an hour.  If i tell it to wait for the file to become unlocked, Robotask stops monitoring for any other files changes until that task is completed.  Not sure if this is a bug or the way ive setup my Task.  Any ideas on how to get it to work whether it is waiting for a file to be unlocked or not?
Thanks!
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Locked Files

Post by Oleg »

Maybe, I've understood not quite correctly what do you want to get...

There are two ways to check whether file is locked:

1. There is system variable {IsFileFree()}. It returns TRUE if file is fully accessible, and FALSE otherwise.
You can use {IsFileFree()} like this:
if {IsFileFree(c:\somefolder\myfile.pdf)}=true then
   .....
   Do something with the file
   .....
Else
   ShowMessage "File is locked by another process"
end if

2. There is "Wait for file" action. This action waits until the file becomes free for access. You can specify some timeout or "Infinity" for waiting. If timeout is over and file is still locked, the action generates error "Timeout is over".
salsaking
Posts: 2
Joined: Wed Oct 18, 2006 7:09 pm

Locked Files

Post by salsaking »

Here's my task in summary:
Trigger Event using File Monitor, when a file is created or changed in a folder, save changes to a file.  Then loop that file and upload the changed file to an FTP server.  All that works fine unless the file is locked.  So i say to wait for it to be unlocked.  Now the problem starts.  Any new files that are added are changed dont get sent to the FTP because the task is waiting for the first file to be unlocked.  Does that make sense?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Locked Files

Post by Oleg »

Why not? Because you do the consecutive processing of files.

I can advise you to not process of locked files and write the name into temporary list (e.g. deferred.txt)
In next calling of the task you should process deferred.txt (and delete it after processing) and, next, process the files retrieved by file monitor.

Another advice:
You can process ALL files in folder and move each file to another folder (or delete it) after the processing. I this case you can easily miss the locked files. They will be processed at next time.
Last edited by Oleg on Fri Oct 20, 2006 4:39 am, edited 1 time in total.
Post Reply