FileScaricaCache
public class FileDownloadCache
extends Object
java.lang.Oggetto | |
↳ | com.android.tradefed.build.FileDownloadCache |
Una classe helper che mantiene una cache LRU del file system locale dei file scaricati.
Riepilogo
Metodi pubblici | |
---|---|
void | deleteCacheEntry (String remoteFilePath) Consenti l'eliminazione di una voce dalla cache. |
void | fetchRemoteFile ( IFileDownloader downloader, String remoteFilePath, File destFile) Scarica il file o collega la cache al file di destinazione. |
File | fetchRemoteFile ( IFileDownloader downloader, String remoteFilePath) Restituisce un file locale corrispondente al remotePath specificato L' |
void | setMaxCacheSize (long numBytes) Imposta la dimensione massima della cache del file locale. |
Metodi protetti | |
---|---|
void | lockFile (String remoteFilePath) Acquisisce il blocco per un file. |
boolean | tryLockFile (String remoteFilePath) Acquisire il blocco per un file solo se non è detenuto da un altro thread. |
void | unlockFile (String remoteFilePath) Tentativo di rilasciare un blocco per un file. |
Metodi pubblici
deleteCacheEntry
public void deleteCacheEntry (String remoteFilePath)
Consenti l'eliminazione di una voce dalla cache. Nel caso in cui la voce non sia valida o danneggiata.
Parametri | |
---|---|
remoteFilePath | String |
fetchRemoteFile
public void fetchRemoteFile (IFileDownloader downloader, String remoteFilePath, File destFile)
Scarica il file o collega la cache al file di destinazione.
Parametri | |
---|---|
downloader | IFileDownloader : IFileDownloader |
remoteFilePath | String : il file remoto. |
destFile | File : il file di destinazione del download. |
Getta | |
---|---|
| com.android.tradefed.build.BuildRetrievalError |
BuildRetrievalError |
fetchRemoteFile
public File fetchRemoteFile (IFileDownloader downloader, String remoteFilePath)
Restituisce un file locale corrispondente al remotePath specificato
L' ERROR(/File)
locale verrà copiato dalla cache se esiste, altrimenti verrà scaricato tramite il dato IFileDownloader
.
Parametri | |
---|---|
downloader | IFileDownloader : IFileDownloader |
remoteFilePath | String : il file remoto. |
ritorna | |
---|---|
File | un ERROR(/File) locale contenente i contenuti di remotePath |
Getta | |
---|---|
BuildRetrievalError | se non è stato possibile recuperare il file |
setMaxCacheSize
public void setMaxCacheSize (long numBytes)
Imposta la dimensione massima della cache del file locale.
La cache non verrà regolata immediatamente se impostata su una dimensione inferiore a quella corrente, ma avrà effetto al prossimo download del file.
Metodi protetti
lockFile
protected void lockFile (String remoteFilePath)
Acquisisce il blocco per un file.
Parametri | |
---|---|
remoteFilePath | String |
tryLockFile
protected boolean tryLockFile (String remoteFilePath)
Acquisire il blocco per un file solo se non è detenuto da un altro thread.
Parametri | |
---|---|
remoteFilePath | String |
ritorna | |
---|---|
boolean | true se il blocco è stato acquisito e false in caso contrario. |
unlockFile
protected void unlockFile (String remoteFilePath)
Tentativo di rilasciare un blocco per un file.
Parametri | |
---|---|
remoteFilePath | String |