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對應的本地文件 如果本地 |
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 | IFileDownloader : IFileDownloader |
remoteFilePath | String :遠程文件。 |
destFile | File :下載的目標文件。 |
投擲 | |
---|---|
BuildRetrievalError |
fetchRemoteFile
public File fetchRemoteFile (IFileDownloader downloader, String remoteFilePath)
返回與給定remotePath對應的本地文件
如果本地ERROR(/File)
存在,將從緩存中復制,否則將通過給定的IFileDownloader
下載。
參量 | |
---|---|
downloader | IFileDownloader : IFileDownloader |
remoteFilePath | String :遠程文件。 |
退貨 | |
---|---|
File | 包含remotePath內容的本地ERROR(/File) |
投擲 | |
---|---|
BuildRetrievalError | 如果無法檢索文件 |
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 |