文件下载缓存包装器
public class FileDownloadCacheWrapper
extends Object
implements IFileDownloader
java.lang.Object |
↳ | com.android.tradefed.build.FileDownloadCacheWrapper |
一个包装类,它在实现IFileDownloader
接口时提供FileDownloadCache
设施。
对于您想从调用者那里抽象出缓存使用的情况很有用。
概括
公共方法 |
---|
void | downloadFile (String remoteFilePath, File destFile) downloadFile(String) 的替代形式,允许调用者指定远程内容应放置的目标文件。 |
File | downloadFile (String remoteFilePath) 将远程文件下载到本地磁盘上的临时文件。 |
void | downloadZippedFiles (File destDir, String remoteFilePath, includeFilters, excludeFilters) downloadZippedFiles (File destDir, String remoteFilePath, includeFilters, excludeFilters) downloadZippedFiles (File destDir, String remoteFilePath, includeFilters, excludeFilters) 在远程 zip 文件中下载与给定过滤器匹配的文件。 |
boolean | isFresh (File localFile, String remoteFilePath) 检查本地文件的新鲜度。 |
公共构造函数
文件下载缓存包装器
public FileDownloadCacheWrapper (File cacheDir,
IFileDownloader delegateDownloader)
参数 |
---|
cacheDir | File |
delegateDownloader | IFileDownloader |
公共方法
下载文件
public void downloadFile (String remoteFilePath,
File destFile)
downloadFile(String)
的替代形式,允许调用者指定远程内容应放置的目标文件。
参数 |
---|
remoteFilePath | String :要下载的文件的远程路径,相对于特定于实现的根目录。 |
destFile | File : 将下载内容放入的文件。不应该存在。 |
下载文件
public File downloadFile (String remoteFilePath)
将远程文件下载到本地磁盘上的临时文件。
参数 |
---|
remoteFilePath | String :要下载的文件的远程路径,相对于特定于实现的根目录。 |
下载压缩文件
public void downloadZippedFiles (File destDir,
String remoteFilePath,
includeFilters,
excludeFilters)
在远程 zip 文件中下载与给定过滤器匹配的文件。
远程 zip 文件中的文件仅下载到其路径匹配任何包含过滤器但不匹配排除过滤器。
参数 |
---|
destDir | File : 将下载内容放入的文件。 |
remoteFilePath | String :要下载的文件的远程路径,相对于特定于实现的根目录。 |
includeFilters | :用于下载匹配文件的过滤器列表。 |
excludeFilters | :用于跳过下载匹配文件的过滤器列表。 |
是新鲜的
public boolean isFresh (File localFile,
String remoteFilePath)
检查本地文件的新鲜度。如果本地文件与远程文件相同,则它是新鲜的。如果不是,则本地文件已过时。这个主要用于缓存。默认实现将始终返回 true,因此如果文件是不可变的,则永远不需要检查新鲜度。
参数 |
---|
localFile | File :本地文件。 |
remoteFilePath | String : 远程文件路径。 |
退货 |
---|
boolean | 如果本地文件是新的则为真,否则为假。 |