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

Coldfusion 11 - java.nio.file.FileSystemException on cffile copy

Community Beginner ,
Apr 21, 2016 Apr 21, 2016

Hi,

I got randomly an error on a cffile copy :

java.nio.file.FileSystemException: D:\netprint\Images\C01332\VISUELHD\SG_OPTEFR_4_Concert.jpg -> D:\netprint\DOC_demandes\ReqSG_00331742\BIB\SG_OPTEFR_4_Concert.jpg: The process cannot access the file because it is being used by another process.

However my code is executing copy only if target file doesn't exist :

<cfif not fileexists("#DEMrepert#/BIB/#NomImageHD#")>

     <cffile action="copy"   source="#BIBrepertHD##NomImageHD#"    destination="#DEMrepert#/BIB">

</cfif>

I am running Coldfusion 11 on windows 2012 R2 server with Java 8 (jdk1.8.0_66).

As destination file doesn't exist, it looks like issue is on source file being locked by another process. Is there a way to check inside coldfusion if source file is locked by another process ?

Regards,

Pierre.

2.3K
Translate
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

correct answers 1 Correct answer

Community Expert , Apr 22, 2016 Apr 22, 2016

There might be issues with concurrent access at the source file as well as at the destination file. The commonest issue with the source file is when one request attempts to read it while a second request is writing it. With the destination, an issue may arise if two separate requests attempt to copy or write to the same file.

You could use a try-catch and lock to handle both cases. The try-catch ensures that the code will continue to run even if the copying results in an error. The lock prevents

...
Translate
LEGEND ,
Apr 21, 2016 Apr 21, 2016

Hi, pierredupli,

Just for poops and smiles, add the 'nameconflict' parameter to the CFFILE tag and set it to makeUnique, and use serverFile as the file name in case it is renamed on conflict.

If that fails, let me know.  I'll keep thinkin' on it.

HTH,

^_^

Translate
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
Community Beginner ,
Apr 22, 2016 Apr 22, 2016

Hi Wolfshade,

Thank you for your answer, however I am using cffile action="copy" and not cffile action="upload", so I don't think this nameConflict parameter is available here.

Regards,

Pierre.

Translate
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
Community Expert ,
Apr 22, 2016 Apr 22, 2016

There might be issues with concurrent access at the source file as well as at the destination file. The commonest issue with the source file is when one request attempts to read it while a second request is writing it. With the destination, an issue may arise if two separate requests attempt to copy or write to the same file.

You could use a try-catch and lock to handle both cases. The try-catch ensures that the code will continue to run even if the copying results in an error. The lock prevents two separate processes from simultaneously accessing a file.

<cftry>

<cfset isImageCopied = fileExists("#DEMrepert#/BIB/#NomImageHD#")>

<cflock name=“imageCopyLock” type=“exclusive” timeout=“10”>

    <cfif NOT isImageCopied>

             <cffile action="copy" source="#BIBrepertHD##NomImageHD#" destination="#DEMrepert#/BIB">

    </cfif>

</cflock>

<cfcatch type="any">

<!--- Log the fact that something went wrong during copying --->

</cfcatch>

</cftry>

If the source file is created elsewhere, then put that code within a lock of the same name:

<cflock name=“imageCopyLock” type=“exclusive” timeout=“20”>

    <!--- Code that creates the file at the location #DEMrepert#/BIB/#NomImageHD# --->

</cflock>

Translate
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
Community Beginner ,
Apr 25, 2016 Apr 25, 2016
LATEST

Thank you very much for this idea.

I have implemented it and I will check how it is behaving with it.

As it was intermittent issue, I will monitor this during few days before knowing if it works..

Thanks again.

Pierre.

De : BKBK

Envoyé : vendredi 22 avril 2016 16:37

À : Pierre THES

Objet : Coldfusion 11 - java.nio.file.FileSystemException on cffile copy

Coldfusion 11 - java.nio.file.FileSystemException on cffile copy

created by BKBK<https://forums.adobe.com/people/BKBK> in ColdFusion - View the full discussion<https://forums.adobe.com/message/8705062#8705062>

Translate
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