Renaming a file takes some time.  I'm not sure how the internals of CF
work - does it send the renaming command off to Windows and then carry
on it merry way?  If so, it may be trying to delete a file that doesn't
exist *yet* at that point in time.

An idea: let a custom tag do the deleting - if the file exists, it gets
deleted; otherwise, it trys again.

<cflock name="arexcelr" type="exclusive" timeout="10">
<cfif FileExists("e:\inetpub\wwwroot\app\junk.txt") is "Yes">
        <cffile action="RENAME" source="e:\inetpub\wwwroot\app\junk.txt"

destination="e:\inetpub\wwwroot\app\junk.del">
        <cf_deleteFile file="e:\inetpub\wwwroot\app\junk.del">
</cfif>
</cflock>

The file, deleteFile.cfm:
<cfif fileExists(attributes.file)>
        <cffile action="DELETE" file="e:\inetpub\wwwroot\app\junk.del">
<cfelse>
        <cf_deleteFile file="#attributes.file#">
</cfif>
        

---
Billy Cravens
Web Development, EDS
[EMAIL PROTECTED]


-----Original Message-----
From: Jack Tumlin [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, September 20, 2001 3:01 PM
To: CF-Talk
Subject: Problem with CFFILE


I having a problem with a piece of code that checks for the existence of
a 
file, renames the file, and then deletes the file. The code is run in a 
child window after the user clicks the submit button on the parent
window. 
The problem occurs when a user closes the child window while the thread
is 
running and then clicks the submit button on the parent window again.

The message appears on the NT Server saying that the file is missing. I 
have tracked it down to the cffile action="RENAME" statement in the code

below. It appears that the first thread is still processing the delete
when 
the second thread is checking for the existence of the file. The first 
thread then finishes and the second thread tries to rename the now 
non-existence file and the error occurs.

Is there something I'm missing with the CFLOCK statement. Also, this is
not 
happening all the time. There is some sort of timing issue. I have read 
where a delete on a NT Server does not happen right away. So, my
question 
has anybody run into a similar problem and came up with a fix?

Here is the code:

<cflock name="arexcelr" type="exclusive" timeout="10">
<cfif FileExists("e:\inetpub\wwwroot\app\junk.txt") is "Yes">
        <cffile action="RENAME" source="e:\inetpub\wwwroot\app\junk.txt"

destination="e:\inetpub\wwwroot\app\junk.del">
        <cffile action="DELETE" file="e:\inetpub\wwwroot\app\junk.del">
</cfif>
</cflock>


Thanks,

Jack Tumlin
Vice President Business Development
Millennium Software, Inc.
The Software Solutions Company
[EMAIL PROTECTED]
www.millsoftinc.com


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to