FileDownloadCacheWrapper

public class FileDownloadCacheWrapper
extends Object implements IFileDownloader

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


這個 wrapper 類別會實作 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, List<String> includeFilters, List<String> 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 暫時下載的本機檔案 File

擲回
BuildRetrievalError

downloadZippedFiles

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

以遠端 ZIP 檔案的形式,下載符合指定篩選條件的檔案。

只有在遠端 ZIP 檔案中的檔案路徑符合任何包含篩選器,但不符合排除篩選器時,才會下載該檔案。

參數
destDir File:要將下載內容放入的檔案。

remoteFilePath String:要下載的檔案的遠端路徑,相對於實作專屬根目錄。

includeFilters List:要下載相符檔案的篩選器清單。

excludeFilters List:要略過下載相符檔案的篩選器清單。

擲回
BuildRetrievalError
IOException

isFresh

public boolean isFresh (File localFile, 
                String remoteFilePath)

檢查本機檔案是否為最新版本。如果本機檔案與遠端檔案相同,則為最新版本。如果不是,本機檔案就是過時的檔案。這項功能主要用於快取。預設實作一律會傳回 true,因此如果檔案不可變更,就不需要檢查是否為最新版本。

參數
localFile File:本機檔案。

remoteFilePath String:遠端檔案路徑。

傳回
boolean 如果本機檔案為最新版本,則為 True,否則為 False。

擲回
BuildRetrievalError