FileDownloadCache

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)

嘗試釋放檔案的鎖定。

公用方法

deleteCacheEntry

public void deleteCacheEntry (String remoteFilePath)

允許從快取中刪除項目。在項目無效或損毀的情況下,

參數
remoteFilePath String

fetchRemoteFile

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

下載檔案或將快取連結至目的檔案。

參數
downloader IFileDownloaderIFileDownloader

remoteFilePath String:遠端檔案。

destFile File:下載的目標檔案。

擲回
BuildRetrievalError

fetchRemoteFile

public File fetchRemoteFile (IFileDownloader downloader, 
                String remoteFilePath)

傳回與指定 remotePath 相對應的本機檔案

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

參數
downloader IFileDownloaderIFileDownloader

remoteFilePath String:遠端檔案。

傳回
File 本機 ERROR(/File),其中包含 remotePath 的內容

擲回
BuildRetrievalError if file could not be retrieved

setMaxCacheSize

public void setMaxCacheSize (long numBytes)

設定本機檔案快取的大小上限。

如果將快取大小設為比目前小,系統不會立即調整,但會在下次下載檔案時生效。

受保護的方法

lockFile

protected void lockFile (String remoteFilePath)

取得檔案的鎖定。

參數
remoteFilePath String

tryLockFile

protected boolean tryLockFile (String remoteFilePath)

只有在檔案未由其他執行緒保留時,才會取得檔案的鎖定。

參數
remoteFilePath String

傳回
boolean 如果取得鎖定,則傳回 true,否則傳回 false。

unlockFile

protected void unlockFile (String remoteFilePath)

嘗試釋放檔案的鎖定。

參數
remoteFilePath String