-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDEV-4949 serve extensions directly for older versions
- Loading branch information
Showing
4 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
component accessors=true { | ||
|
||
property name="extensionCache" type="any" default="cache/extensions/"; | ||
|
||
function getExtensionLex( extensionUrl ){ | ||
var filename = listLast( arguments.extensionUrl, "/"); | ||
var cachedir = expandPath( variables.extensionCache ); | ||
|
||
if ( !directoryExists( cachedir ) ){ | ||
directoryCreate( cachedir ); | ||
} else if ( fileExists ( cachedir & filename )) { | ||
return cachedir & filename; | ||
} | ||
lock name="ext-#filename#" type="exclusive" timeout=10 { | ||
return _fetchExtensionLex( cachedir, arguments.extensionUrl ) | ||
} | ||
|
||
if ( fileExists ( cachedir & filename ) ) { | ||
return cachedir & filename; | ||
} | ||
throw "unable to find extension [#filename#]"; | ||
} | ||
|
||
private function _fetchExtensionLex( string cachedir, string extensionUrl ){ | ||
var filename = listLast( arguments.extensionUrl, "/"); | ||
if ( fileExists ( cachedir & filename )) { | ||
return cachedir & filename; | ||
} | ||
systemOutput( "Downloading #arguments.extensionUrl# (cache miss)", true); | ||
http url=arguments.extensionUrl method="get" result="local.core" path=cachedir; | ||
var file = directoryList(path=cachedir, filter="#filename#"); | ||
// systemOutput(file, true); | ||
return file[ 1 ]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" labels="data-provider-integration" { | ||
|
||
function beforeAll (){ | ||
variables.dir = getDirectoryFromPath(getCurrentTemplatePath()); | ||
application action="update" mappings={ | ||
"/services" : expandPath( dir & "../apps/updateserver/services" ) | ||
}; | ||
variables.artifacts = dir & "/artifacts"; | ||
if ( !DirectoryExists( variables.artifacts )) | ||
directoryCreate( variables.artifacts ); | ||
|
||
variables.buildDir = getTempDirectory() & "/build-test-#createUniqueId()#/"; | ||
if ( DirectoryExists( variables.buildDir ) ) | ||
directoryDelete( variables.buildDir, true ); | ||
directoryCreate( variables.buildDir, true ); | ||
|
||
} | ||
|
||
function run( testResults , testBox ) { | ||
describe( "extensions need to be served directly for older lucee versions", function() { | ||
it(title="check local extension cache works", body=function(){ | ||
var extensionCache = new services.extensionCache(); | ||
var path = extensionCache.getExtensionLex( "https://ext.lucee.org/compress-extension-1.0.0.15.lex" ); | ||
systemOutput( path, true ) | ||
expect( fileExists( path ) ).toBeTrue(); | ||
}); | ||
|
||
it(title="check local extension cache works (from cache)", body=function(){ | ||
var extensionCache = new services.extensionCache(); | ||
var path = extensionCache.getExtensionLex( "https://ext.lucee.org/compress-extension-1.0.0.15.lex" ); | ||
// systemOutput( path, true ) | ||
expect( fileExists( path ) ).toBeTrue(); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
} |