• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFFILE Holding File Locks

New Here ,
Nov 08, 2007 Nov 08, 2007

Copy link to clipboard

Copied

I have a CF page that reads some tab-delimited text files for processing. After it reads a file it then calls a CF page to move the file to a new location. It moves the file, but it does not delete the old version -- and a filesystem delete on the file fails -- it appears as if the CF server has the file locked. If I shut down the server and restart it, it clears the lock.

<cfif #url.vendor# is "LOWES">
<cflock timeout="10" scope="server" throwOnTimeout="no" type="exclusive">
<cffile action="move"
source="c:\edifiles\export\#url.fileno#"
destination="c:\edifiles\export\done\lowes\#url.fileno#">
</cflock>
</cfif>
TOPICS
Advanced techniques

Views

727

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2007 Nov 08, 2007

Copy link to clipboard

Copied

Looks like rename locks itself -- the attached block solves the problem

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 08, 2007 Nov 08, 2007

Copy link to clipboard

Copied

Generally when manipulating files you used a named <cflock> instead of a scope like so:

<cflock name="#Variables.myFileName#" timeout="5" type="exclusive">

In your code in the second example I'm not sure about the function of the loop at all... I guess you are trying to delay to make sure the copy operation completes before deleting. But looping from 1 to 10 is arbitrary and depending on other concurrent processes, server speed, RAM, etc. and so basically it is unreliable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 08, 2007 Nov 08, 2007

Copy link to clipboard

Copied

LATEST
Perhaps they mean changing from a "move" to a "copy" + "delete" resolved the problem.

> used a named <cflock> instead
Yes, consider using a more granular lock, instead of placing an exclusive lock on the server scope. Though it looks like locking was removed entirely from the final code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation