文件下載快取

public class FileDownloadCache
extends Object

java.lang.Object
com.android.tradefed.build.FileDownloadCache


維護下載檔案的本機檔案系統 LRU 快取的幫助程式類別。

概括

公共方法

void deleteCacheEntry (String remoteFilePath)

允許從快取中刪除條目。

void fetchRemoteFile ( IFileDownloader downloader, String remoteFilePath, File destFile)

下載檔案或將快取連結到目標檔案。

File fetchRemoteFile ( IFileDownloader downloader, String remoteFilePath)

傳回給定remotePath對應的本機文件

如果存在本機ERROR(/File)將從快取中複製,否則將透過給定的IFileDownloader下載。

void setMaxCacheSize (long numBytes)

設定本地文件快取的最大大小。

受保護的方法

void lockFile (String remoteFilePath)

取得文件的鎖。

boolean tryLockFile (String remoteFilePath)

僅當檔案未被其他執行緒持有時才取得該檔案的鎖定。

void unlockFile (String remoteFilePath)

嘗試釋放文件的鎖。

公共方法

刪除快取條目

public void deleteCacheEntry (String remoteFilePath)

允許從快取中刪除條目。如果條目無效或損壞。

參數
remoteFilePath String

取得遠端文件

public void fetchRemoteFile (IFileDownloader downloader, 
                String remoteFilePath, 
                File destFile)

下載檔案或將快取連結到目標檔案。

參數
downloader IFileDownloader : IFileDownloader

remoteFilePath String : 遠端檔案。

destFile File :下載的目標檔案。

投擲
com.android.tradefed.build.BuildRetrievalError
BuildRetrievalError

取得遠端文件

public File fetchRemoteFile (IFileDownloader downloader, 
                String remoteFilePath)

傳回給定remotePath對應的本機文件

如果存在本機ERROR(/File)將從快取中複製,否則將透過給定的IFileDownloader下載。

參數
downloader IFileDownloader : IFileDownloader

remoteFilePath String : 遠端檔案。

退貨
File包含remotePath內容的本機ERROR(/File)

投擲
BuildRetrievalError如果無法檢索文件

設定最大快取大小

public void setMaxCacheSize (long numBytes)

設定本地文件快取的最大大小。

如果設定為小於目前大小,快取不會立即調整,而是在下次文件下載時生效。

受保護的方法

鎖定文件

protected void lockFile (String remoteFilePath)

取得文件的鎖。

參數
remoteFilePath String

嘗試鎖定文件

protected boolean tryLockFile (String remoteFilePath)

僅當檔案未被其他執行緒持有時才取得該檔案的鎖定。

參數
remoteFilePath String

退貨
boolean如果取得了鎖則為 true,否則為 false。

解鎖文件

protected void unlockFile (String remoteFilePath)

嘗試釋放文件的鎖。

參數
remoteFilePath String