FileDownloadCacheWrapper

public class FileDownloadCacheWrapper
extends Object implements IFileDownloader

java.lang.Object
   ↳ com.android.tradefed.build.FileDownloadCacheWrapper


封装容器类,用于在实现 IFileDownloader 接口时提供 FileDownloadCache 设施。

如果您想将缓存的使用情况从调用方抽象出来,此方法非常有用。

摘要

公共构造函数

FileDownloadCacheWrapper(File cacheDir, IFileDownloader delegateDownloader)

公共方法

void downloadFile(String remoteFilePath, File destFile)

downloadFile(String) 的替代形式,允许调用方指定应将远程内容放入的目的地文件。

File downloadFile(String remoteFilePath)

将远程文件下载到本地磁盘上的临时文件。

void downloadZippedFiles(File destDir, String remoteFilePath, includeFilters, excludeFilters)

下载与给定过滤条件匹配的远程 zip 文件中的文件。

boolean isFresh(File localFile, String remoteFilePath)

检查本地文件的新鲜度。

公共构造函数

FileDownloadCacheWrapper

public FileDownloadCacheWrapper (File cacheDir, 
                IFileDownloader delegateDownloader)

参数
cacheDir File

delegateDownloader IFileDownloader

公共方法

downloadFile

public void downloadFile (String remoteFilePath, 
                File destFile)

downloadFile(String) 的替代形式,允许调用方指定应将远程内容放入的目的地文件。

参数
remoteFilePath String:相对于特定实现的根目录的要下载的文件的远程路径。

destFile File:要将下载内容放入其中的文件。不应存在。

抛出
BuildRetrievalError

downloadFile

public File downloadFile (String remoteFilePath)

将远程文件下载到本地磁盘上的临时文件。

参数
remoteFilePath String:相对于实现专用根目录的要下载的文件的远程路径。

返回
File 临时本地下载的 ERROR(/File)

抛出
BuildRetrievalError

downloadZippedFiles

public void downloadZippedFiles (File destDir, 
                String remoteFilePath, 
                 includeFilters, 
                 excludeFilters)

下载与给定过滤条件匹配的远程 zip 文件中的文件。

远程 ZIP 文件中的文件仅会下载到其路径与任何包含过滤条件(而非排除过滤条件)匹配的位置。

参数
destDir File:要将下载内容放入其中的文件。

remoteFilePath String:相对于实现专用根目录的要下载的文件的远程路径。

includeFilters :用于下载匹配文件的过滤条件列表。

excludeFilters :用于跳过下载匹配文件的过滤条件列表。

抛出
BuildRetrievalError

isFresh

public boolean isFresh (File localFile, 
                String remoteFilePath)

检查本地文件的新鲜度。如果本地文件与远程文件相同,则表示本地文件是最新的。否则,本地文件已过时。这主要用于缓存。默认实现始终会返回 true,因此如果文件是不可变的,则永远无需检查新鲜度。

参数
localFile File:本地文件。

remoteFilePath String:远程文件路径。

返回
boolean 如果本地文件是新鲜的,则返回 true,否则返回 false。

抛出
BuildRetrievalError