tracker issue : CF-3040435

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 80741:When copying a directory (using cffile and cfdirectory tags) and then trying to delete the source directory it appears that certain files are remaining locked resulting in the following error: Coldfu

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): Tom Bishop / Tom Bishop (windz)

Created: 11/20/2009

Components: File Management, VFS-S3

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Win All

Vote Count: 0

Problem:

When copying a directory (using cffile and cfdirectory tags) and then trying to delete the source directory it appears that certain files are remaining locked resulting in the following error:  Coldfusion was unable todelete the file [specific path] for an unknown reasonIt is an occasional error (the code supplied below works 90% of the time).This error, I see, has been reported (and apparently fixed) with CF8.0.1 hot fix. Please see the following page:  http://forums.adobe.com/thread/98508The code supplied works. It is perhaps one in 100 files that throws this error. Perhaps it is related to large files being moved around and becoming locked which are then unable to be  deleted by the same thread. I have tried using <cfthread action="sleep"> for durations of 1000 to 5000 milliseconds but the error still happens occasionally. If I sleep the thread for any longer it slows processing down to a snails pace.Obviously there are workarounds but this code should work perfectly. Hence this bug report.
Method:

<cffunction name="ArchiveSoldAndShippedSalesLotImages" returntype="void" access="public" output="no"><cfthread name="#createuuid()#" action="run"><cfset var saleslotQuery = variables.ormSvc.createGateway("saleslot").GetAllSoldAndShippedSalesLots(idonly=true)><cfloop query="saleslotQuery"><cfset saleslotrecord = variables.ormSvc.createRecord("saleslot").load(saleslotid=saleslotQuery.saleslotid)><!--- Sales Lot Images First ---><cfif directoryexists("#expandpath(variables.imagemapping)#\saleslotimages\#saleslotQuery.saleslotid#")><cfdirectory action="list"  directory="#expandpath(variables.imagemapping)#\saleslotimages\#saleslotQuery.saleslotid#" name="saleslotdir"><cfif saleslotdir.recordcount gt 0><cfset directoryCopy("#expandpath(variables.imagemapping)#\saleslotimages\#saleslotQuery.saleslotid#","#expandpath(variables.imagemapping)#\archived\saleslotimages\#saleslotQuery.saleslotid#")><cfdirectory action="delete" directory="#expandpath(variables.imagemapping)#\saleslotimages\#saleslotQuery.saleslotid#" recurse="yes"><cfelse><cfdirectory action="delete" directory="#expandpath(variables.imagemapping)#\saleslotimages\#saleslotQuery.saleslotid#" recurse="yes"></cfif></cfif><cfset skuArray = saleslotrecord.getskuiterator().getArray()><!--- Then SKU images ---><cfloop from="1" to="#arraylen(skuArray)#" index="i"><cfset skuid = skuArray[i].getskuid()><cfif directoryexists("#expandpath(variables.imagemapping)#\skuimages\#skuid#")><cfset directoryCopy("#expandpath(variables.imagemapping)#\skuimages\#skuid#","#expandpath(variables.imagemapping)#\archived\skuimages\#skuid#")><cfdirectory action="delete" directory="#expandpath(variables.imagemapping)#\skuimages\#skuid#" recurse="yes"></cfif></cfloop></cfloop><cfset saleslotrecord = ""></cfthread></cffunction><cffunction name="directoryCopy" output="true" access="private"><cfargument name="source" required="true" type="string"><cfargument name="destination" required="true" type="string"><cfargument name="nameconflict" required="true" default="overwrite"><cfset var contents = "" /><cfset var dirDelim = "/"><cfif server.OS.Name contains "Windows"><cfset dirDelim = "\" /></cfif><cfif not(directoryExists(arguments.destination))><cfdirectory action="create" directory="#arguments.destination#"></cfif><cfdirectory action="list" directory="#arguments.source#" name="contents"><cfloop query="contents"><cfif contents.type eq "file"><cffile action="copy" source="#arguments.source#\#name#" destination="#arguments.destination#\#name#" nameconflict="#arguments.nameConflict#"><cfelseif contents.type eq "dir"><cfset directoryCopy(arguments.source & dirDelim & name, arguments.destination & dirDelim &  name) /></cfif></cfloop></cffunction>
Result:

"Error","cfthread-0","11/20/09","12:33:02",,"A08C4046-03B5-53D9-E16AF52E0DEA694C: ColdFusion could not delete the file D:\Images\skuimages\4475 for an unknown reason. "coldfusion.tagext.io.FileUtils$CouldNotDeleteFileException: ColdFusion could not delete the file D:\Images\skuimages\4475 for an unknown reason.at coldfusion.tagext.io.FileUtils.recursiveRemoveDir(FileUtils.java:262)at coldfusion.tagext.io.FileUtils.deleteDirectory(FileUtils.java:230)at coldfusion.tagext.io.DirectoryTag.doStartTag(DirectoryTag.java:278)at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)at cfimages2ecfc441605675$func_CFFUNCCFTHREAD_CFIMAGES2ECFC4416056751.runFunction(C:\inetpub\wwwroot\stockbase\model\services\images.cfc:892)at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)at coldfusion.runtime.UDFMethod.invokeCFThread(UDFMethod.java:201)at coldfusion.thread.Task.invokeFunction(Task.java:274)at coldfusion.thread.Task.run(Task.java:140)at coldfusion.scheduling.ThreadPool.run(ThreadPool.java:201)at coldfusion.scheduling.WorkerThread.run(WorkerThread.java:71)

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3040435

External Customer Info:
External Company:  
External Customer Name: Tom Bishop
External Customer Email: 4AD70C9C40D195E2992016B6
External Test Config: 11/20/2009

Attachments:

Comments: