FileDownloadCache
public
class
FileDownloadCache
extends Object
java.lang.Object | |
↳ | com.android.tradefed.build.FileDownloadCache |
Một lớp trợ giúp duy trì bộ nhớ đệm LRU của hệ thống tệp cục bộ cho các tệp đã tải xuống.
Tóm tắt
Phương thức công khai | |
---|---|
void
|
deleteCacheEntry(String remoteFilePath)
Cho phép xoá một mục nhập khỏi bộ nhớ đệm. |
void
|
fetchRemoteFile(IFileDownloader downloader, String remoteFilePath, File destFile)
Tải tệp xuống hoặc liên kết bộ nhớ đệm với tệp đích. |
File
|
fetchRemoteFile(IFileDownloader downloader, String remoteFilePath)
Trả về một tệp cục bộ tương ứng với remotePath đã cho
|
void
|
setMaxCacheSize(long numBytes)
Đặt kích thước tối đa của bộ nhớ đệm tệp cục bộ. |
Phương thức được bảo vệ | |
---|---|
void
|
lockFile(String remoteFilePath)
Thuê bao khoá cho một tệp. |
boolean
|
tryLockFile(String remoteFilePath)
Chỉ có thể lấy khoá cho một tệp nếu tệp đó không do một luồng khác giữ. |
void
|
unlockFile(String remoteFilePath)
Cố gắng huỷ khoá một tệp. |
Phương thức công khai
deleteCacheEntry
public void deleteCacheEntry (String remoteFilePath)
Cho phép xoá một mục nhập khỏi bộ nhớ đệm. Trong trường hợp mục nhập không hợp lệ hoặc bị hỏng.
Tham số | |
---|---|
remoteFilePath |
String |
fetchRemoteFile
public void fetchRemoteFile (IFileDownloader downloader, String remoteFilePath, File destFile)
Tải tệp xuống hoặc liên kết bộ nhớ đệm với tệp đích.
Tham số | |
---|---|
downloader |
IFileDownloader : IFileDownloader |
remoteFilePath |
String : tệp từ xa. |
destFile |
File : Tệp đích của tệp tải xuống. |
Gửi | |
---|---|
BuildRetrievalError |
fetchRemoteFile
public File fetchRemoteFile (IFileDownloader downloader, String remoteFilePath)
Trả về một tệp cục bộ tương ứng với remotePath đã cho
ERROR(/File)
cục bộ sẽ được sao chép từ bộ nhớ đệm nếu có, nếu không sẽ được tải xuống thông qua IFileDownloader
đã cho.
Tham số | |
---|---|
downloader |
IFileDownloader : IFileDownloader |
remoteFilePath |
String : tệp từ xa. |
Giá trị trả về | |
---|---|
File |
ERROR(/File) cục bộ chứa nội dung của remotePath |
Gửi | |
---|---|
BuildRetrievalError |
nếu không thể truy xuất tệp |
setMaxCacheSize
public void setMaxCacheSize (long numBytes)
Đặt kích thước tối đa của bộ nhớ đệm tệp cục bộ.
Bộ nhớ đệm sẽ không được điều chỉnh ngay lập tức nếu bạn đặt kích thước nhỏ hơn kích thước hiện tại, nhưng sẽ có hiệu lực trong lần tải tệp tiếp theo.
Phương thức được bảo vệ
lockFile
protected void lockFile (String remoteFilePath)
Thuê bao khoá cho một tệp.
Tham số | |
---|---|
remoteFilePath |
String |
tryLockFile
protected boolean tryLockFile (String remoteFilePath)
Chỉ có thể lấy khoá cho một tệp nếu tệp đó không do một luồng khác giữ.
Tham số | |
---|---|
remoteFilePath |
String |
Giá trị trả về | |
---|---|
boolean |
true nếu đã có khoá và false nếu không. |
unlockFile
protected void unlockFile (String remoteFilePath)
Cố gắng huỷ khoá một tệp.
Tham số | |
---|---|
remoteFilePath |
String |