文件下載快取包裝器

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) 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 :放置下載內容的檔案。不應該存在。

投擲
BuildRetrievalError

下載文件

public File downloadFile (String remoteFilePath)

將遠端檔案下載到本機磁碟上的暫存檔案。

參數
remoteFilePath String :要下載的檔案的遠端路徑,相對於特定實作的根。

退貨
File臨時本地下載的ERROR(/File)

投擲
BuildRetrievalError

下載壓縮文件

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

下載遠端 zip 檔案中與給定過濾器相符的檔案。

遠端 zip 檔案內的檔案僅下載到與任何包含過濾器相符但不與排除過濾器相符的路徑。

參數
destDir File :放置下載內容的檔案。

remoteFilePath String :要下載的檔案的遠端路徑,相對於特定實作的根。

includeFilters :用於下載匹配文件的過濾器列表。

excludeFilters :跳過下載匹配文件的過濾器列表。

投擲
BuildRetrievalError

新鮮

public boolean isFresh (File localFile, 
                String remoteFilePath)

檢查本地文件的新鮮度。如果本地文件與遠端文件相同,則它是新鮮的。如果不是,則本機檔案已過時。這主要用於緩存。預設實作將始終傳回 true,因此如果檔案是不可變的,則它將永遠不需要檢查新鮮度。

參數
localFile File :本地文件。

remoteFilePath String :遠端檔案路徑。

退貨
boolean如果本機檔案是最新的,則為 true,否則為 false。

投擲
BuildRetrievalError