Write Permission Issue on Contribute File Deployer?

219 Views Asked by At

I've been using Contribute's File Deployer tool for some time, and it's worked wonderfully until we replaced the servers that it pushes files to. Pushing files by itself works fine, permissions and all. But part of the main feature is it scans the directory that your file is being pushed to, and if it doesn't exist then it creates said directory.

As of now, it's always failing on this part of the tool. The format of the full path of the file being pushed is \\\x.x.x.x\sync$\path/to/folder (the mixed slashes always work.)

This is on Windows XP sp3 with ColdFusion 8.

<cftry>
            <cfinvoke method="MakeSurePathExists" path="#serverPathToPush##siteRelative#">
            <cfcatch type="any">
                <cfthrow errorcode="NoLiveServerAccess" message="Can not access or do not have sufficient permissions to write to: #serverPathToPush##siteRelative#">
                <cflog application="yes" text="Can not access or do not have sufficient permissions to write to: #serverPathToPush##siteRelative#" file="Filedeployer" />
            </cfcatch>
        </cftry>

    <cffile action="copy" source="#settings.stagingFileSystemPath & siteRelative#" destination="#serverPathToPush##siteRelative#">
    <!--- touch the file so it gets the current date, so the browser will pull down the new one when previewed --->
    <cffile action="append" file="#serverPathToPush##siteRelative#" output="">

<!--- This function checks if the directory exist of the given file.
         If it doesn't, it tries to build path. If it fails, the function throws --->
    <cffunction name="MakeSurePathExists">
        <cfargument name="path" type="string" required="true">

        <cfset createList = ArrayNew(1)>
        <cfinvoke method="RemoveLastFileFromPath" path="#path#" returnvariable="parentdir">

        <cfloop condition="not DirectoryExists( parentDir ) and Len( parentDir ) gt 0 ">
            <cfset temp = ArrayAppend( createList, parentDir ) >
            <cfinvoke method="RemoveLastFileFromPath" path="parentdir" returnvariable="parentdir">
        </cfloop>

        <cfloop from="#ArrayLen( createList )#" to="1" step="-1" index="index">
            <cfdirectory action="create" directory="#createList[index]#">
        </cfloop>
    </cffunction>

    <cfscript>

        function RemoveLastFileFromPath( path )
        {
            rpath = Reverse( path ) ;
            idx2 = Find( "\", rpath ) ;
            idx = Find( "/", rpath ) ;
            if( idx2 is not "0" and idx2 lt idx )
                idx = idx2 ;
            if( idx is not "0" ) {
                rpath = Right( rpath, Len(rpath) - idx ) ;
                return Reverse( rpath ) ;
            }
            return "" ;
        }
    </cfscript>

The friendly error I get is:

Can not access or do not have sufficient permissions to write to: \x.x.x.x.\sync$\ path/to/folder/the-file.cfm

CFDUMP's Error:

The most likely cause of this error is that \x.x.x.x.\sync$\ path/to/folder/already exists on your file system. The exception occurred during a cfdirectory action="create".

I'm aware of the space between the end of the share URL and the relative path. Again, this has not been an issue before, and I'm not sure that it is now.

1

There are 1 best solutions below

0
On

It turns out, in this case, the space in the URL is affecting the push. I had to add a trim() around the server address, and that resolved the issue. However, why it is only an issue now and not before I will never know.