add special property to disable cache for the next get. Unlike other Ant properties, this
one can be rewritten
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/4bd7d958
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/4bd7d958
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/4bd7d958
Branch: refs/heads/develop
Commit: 4bd7d958b111e27781faad41d6867353b107a3a7
Parents: ec80dba
Author: Alex Harui <aharui@apache.org>
Authored: Sun Mar 2 20:51:04 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Sun Mar 2 20:51:04 2014 -0800
----------------------------------------------------------------------
ant_on_air/src/org/apache/flex/ant/Ant.as | 5 +++
ant_on_air/src/org/apache/flex/ant/tags/Get.as | 41 +++++++++++++++++++-
.../src/org/apache/flex/ant/tags/Property.as | 7 ++++
3 files changed, 52 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4bd7d958/ant_on_air/src/org/apache/flex/ant/Ant.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/Ant.as b/ant_on_air/src/org/apache/flex/ant/Ant.as
index a3b28d8..b6cde1e 100644
--- a/ant_on_air/src/org/apache/flex/ant/Ant.as
+++ b/ant_on_air/src/org/apache/flex/ant/Ant.as
@@ -42,6 +42,11 @@ package org.apache.flex.ant
}
/**
+ * Special property used to disable caching temporarily in Get task
+ */
+ public static const DO_NOT_CACHE_NEXT_GET:String = "do-not-cache-next-get";
+
+ /**
* @private
* The file being processed. Used to determine basedir.
*/
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4bd7d958/ant_on_air/src/org/apache/flex/ant/tags/Get.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Get.as b/ant_on_air/src/org/apache/flex/ant/tags/Get.as
index 8c70f37..a02e6ad 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Get.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Get.as
@@ -68,11 +68,18 @@ package org.apache.flex.ant.tags
}
private var urlLoader:URLLoader;
+ private var doNotCacheNextGet:Boolean;
override public function execute(callbackMode:Boolean, context:Object):Boolean
{
super.execute(callbackMode, context);
+ if (context[Ant.DO_NOT_CACHE_NEXT_GET])
+ {
+ doNotCacheNextGet = true;
+ context[Ant.DO_NOT_CACHE_NEXT_GET] = false;
+ }
+
if (skipexisting)
{
var destFile:File = getDestFile();
@@ -89,6 +96,8 @@ package org.apache.flex.ant.tags
var actualSrc:String = src;
if (Ant.usingDownloadCache)
{
+ if (context.verbose)
+ ant.output(ant.formatOutput("get", "download cache is enabled"));
if (src.indexOf("http") == 0)
{
var c:int = src.indexOf("/");
@@ -97,8 +106,20 @@ package org.apache.flex.ant.tags
// that should find the slash after the server.
var cacheFile:File = File.applicationStorageDirectory.resolvePath(Ant.downloadCacheFolder);
cacheFile = cacheFile.resolvePath(src.substr(c + 1));
+ if (context.verbose)
+ ant.output(ant.formatOutput("get", "cached file is " + cacheFile.url));
if (cacheFile.exists)
+ {
actualSrc = cacheFile.url;
+ if (context.verbose)
+ ant.output(ant.formatOutput("get", "found file in cache"));
+ }
+ else
+ {
+ if (context.verbose)
+ ant.output(ant.formatOutput("get", "did not find file in cache"));
+
+ }
}
}
var urlRequest:URLRequest = new URLRequest(actualSrc);
@@ -193,8 +214,15 @@ package org.apache.flex.ant.tags
fs.writeBytes(urlLoader.data as ByteArray);
fs.close();
}
- if (Ant.usingDownloadCache)
+ if (context.verbose && doNotCacheNextGet)
+ ant.output(ant.formatOutput("get", "caching disabled by do-not-cache-next-get"));
+ if (Ant.usingDownloadCache && !doNotCacheNextGet)
{
+ if (context.verbose)
+ {
+ ant.output(ant.formatOutput("get", "Download complete, cache is enabled"));
+ ant.output(ant.formatOutput("get", "Source url is: " + src));
+ }
if (src.indexOf("http") == 0)
{
var c:int = src.indexOf("/");
@@ -203,8 +231,19 @@ package org.apache.flex.ant.tags
// that should find the slash after the server.
var cacheFile:File = File.applicationStorageDirectory.resolvePath(Ant.downloadCacheFolder);
cacheFile = cacheFile.resolvePath(src.substr(c + 1));
+ if (context.verbose)
+ ant.output(ant.formatOutput("get", "cached file is " + cacheFile.url));
if (!cacheFile.exists)
+ {
+ if (context.verbose)
+ ant.output(ant.formatOutput("get", "adding file to cache"));
destFile.copyTo(cacheFile);
+ }
+ else
+ {
+ if (context.verbose)
+ ant.output(ant.formatOutput("get", "file already in cache"));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/4bd7d958/ant_on_air/src/org/apache/flex/ant/tags/Property.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Property.as b/ant_on_air/src/org/apache/flex/ant/tags/Property.as
index 1b52893..811e6b6 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Property.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Property.as
@@ -51,6 +51,13 @@ package org.apache.flex.ant.tags
{
super.execute(callbackMode, context);
+ if (name == Ant.DO_NOT_CACHE_NEXT_GET)
+ {
+ // special case this flag. Overwrite if already defined
+ context[name] = value;
+ return true;
+ }
+
if (name && (value || location || refid) && !context.hasOwnProperty(name))
{
if (value)
|