CDN changes breaking image generation?

14 views
Skip to first unread message

Sean Coyne

unread,
Aug 30, 2013, 3:07:35 PM8/30/13
to farcr...@googlegroups.com
We had some image regeneration scripts and when we changed over to FarCry 6.3 recently they stopped working properly.

The change seems to be related to the CDN stuff.

We were calling generateImage() from the Image formtool and passing the source and destination arguments as FULL disk paths.

<cffunction name="GenerateImage" access="public" output="false" returntype="struct">
 
<cfargument name="source" type="string" required="true" hint="The absolute path where the image that is being used to generate this new image is located." />
 
<cfargument name="destination" type="string" required="false" default="" hint="The absolute path where the image will be stored." />

Now, when we do this, the CDN transforms the path by prepending the FULL disk path to the webroot.  So if we pass in /sites/farcry/projects/projectname/www/images/someType/imgTeaser/somefile.jpg the CDN stuff turns this into 

/sites/farcry/projects/projectname/www/sites/farcry/projects/projectname/www/images/someType/imgTeaser/somefile.jpg

when checking if the file exists:

<cfif not application.fc.lib.cdn.ioFileExists(location="images",file=arguments.source)>
 
<cfset stResult.bSuccess = False />
 
<cfset stResult.message = "File doesn't exist" />
 
<cfreturn stResult />
</cfif>

which calls this in the local CDN component:

<cffunction name="ioFileExists" returntype="boolean" access="public" output="false" hint="Checks that a specified path exists">
 
<cfargument name="config" type="struct" required="true" />
 
<cfargument name="file" type="string" required="true" />
 
 
<cfreturn fileexists(getFullPath(config=arguments.config,file=arguments.file)) />
 
</cffunction>

leading to this culprit:

<cffunction name="getFullPath" output="false" access="public" returntype="string" hint="Returns full internal path. Works for files and directories.">
 
<cfargument name="config" type="struct" required="true" />
 
<cfargument name="file" type="string" required="true" />
 
 
<cfset var fullpath = "" />
 
 
<cfif left(arguments.file,1) eq "/">
 
<cfset fullpath = arguments.config.fullpath & arguments.file />
 
<cfelse>
 
<cfset fullpath = arguments.config.fullpath & "/" & arguments.file />
 
</cfif>
 
 
<cfreturn fullpath />
 
</cffunction>


So, shouldn't getFullPath first check to make sure that the "file" passed in isn't ALREADY the full path??

In our case ioFileExists was returning false even though the file does exist because it was messing up the path.

I have fixed our issue by only passing in webroot relative paths instead of the full disk path but this is a backwards compatibility issue for people who are manually calling GenerateImage()

Thoughts?

Sean

Sean Coyne

unread,
Aug 30, 2013, 3:10:20 PM8/30/13
to farcr...@googlegroups.com
I should mention I saw this while running on a Mac.  I havent tested against our production Windows instance yet.

Jeff Coughlin

unread,
Aug 30, 2013, 3:31:13 PM8/30/13
to farcr...@googlegroups.com
Ouch. Hmm... I'll have to think about it. I think it might break something else to (unrelated).

--
Jeff Coughlin
--
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcr...@googlegroups.com
To unsubscribe, email: farcry-dev+...@googlegroups.com
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
---
You received this message because you are subscribed to the Google Groups "farcry-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to farcry-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sean Coyne

unread,
Aug 30, 2013, 3:36:36 PM8/30/13
to farcr...@googlegroups.com
Jeff I found it using your imageRegenerateFromSource() UDF.  I made the required changes on MHPC not on MHS yet though.  Want to test on Windows first.

Sean Coyne

unread,
Aug 30, 2013, 3:45:53 PM8/30/13
to farcr...@googlegroups.com
Same thing on Windows

Jeff Coughlin

unread,
Aug 30, 2013, 3:47:13 PM8/30/13
to farcr...@googlegroups.com
Yeah, that's the other thing I was thinking about. Might have to rewrite/update that UDF.

--
Jeff Coughlin

Sean Coyne

unread,
Aug 30, 2013, 3:52:46 PM8/30/13
to farcr...@googlegroups.com
Yes we do.  I'll fix.
Reply all
Reply to author
Forward
0 new messages