IFileDownloader

public interface IFileDownloader

com.android.tradefed.build.IFileDownloader


Interface for downloading a remote file.

Summary

Public methods

default void acquireDownloadPermit()

If concurrency limit is supported, take a download permit.

default void downloadFile(String remoteFilePath, File destFile, long startOffset, long size)

Alternate form of downloadFile(String, File), that allows caller to download a section of the file and save to a specific destination file.

abstract void downloadFile(String relativeRemotePath, File destFile)

Alternate form of downloadFile(String), that allows caller to specify the destination file the remote contents should be placed in.

abstract File downloadFile(String remoteFilePath)

Downloads a remote file to a temporary file on local disk.

default void downloadZippedFiles(File destDir, String remoteFilePath, includeFilters, excludeFilters)

Download the files matching given filters in a remote zip file.

default boolean isFresh(File localFile, String remoteFilePath)

Check local file's freshness.

default void releaseDownloadPermit()

If concurrency limit is supported, release a download permit.

Public methods

acquireDownloadPermit

public void acquireDownloadPermit ()

If concurrency limit is supported, take a download permit.

downloadFile

public void downloadFile (String remoteFilePath, 
                File destFile, 
                long startOffset, 
                long size)

Alternate form of downloadFile(String, File), that allows caller to download a section of the file and save to a specific destination file.

Parameters
remoteFilePath String: the remote path to the file to download, relative to an implementation-specific root.

destFile File: the file to place the downloaded contents into. Should not exist.

startOffset long: the start offset in the remote file.

size long: the number of bytes to download from the remote file. Set it to a negative value to download the whole file.

Throws
BuildRetrievalError if file could not be downloaded

downloadFile

public abstract void downloadFile (String relativeRemotePath, 
                File destFile)

Alternate form of downloadFile(String), that allows caller to specify the destination file the remote contents should be placed in.

Parameters
relativeRemotePath String: the remote path to the file to download, relative to an implementation-specific root.

destFile File: the file to place the downloaded contents into. Should not exist.

Throws
BuildRetrievalError if file could not be downloaded

downloadFile

public abstract File downloadFile (String remoteFilePath)

Downloads a remote file to a temporary file on local disk.

Parameters
remoteFilePath String: the remote path to the file to download, relative to a implementation specific root.

Returns
File the temporary local downloaded ERROR(/File).

Throws
BuildRetrievalError if file could not be downloaded

downloadZippedFiles

public void downloadZippedFiles (File destDir, 
                String remoteFilePath, 
                 includeFilters, 
                 excludeFilters)

Download the files matching given filters in a remote zip file.

A file inside the remote zip file is only downloaded to its path matches any of the include filters but not the exclude filters.

Parameters
destDir File: the file to place the downloaded contents into.

remoteFilePath String: the remote path to the file to download, relative to an implementation specific root.

includeFilters : a list of filters to download matching files.

excludeFilters : a list of filters to skip downloading matching files.

Throws
BuildRetrievalError if files could not be downloaded.
IOException

isFresh

public boolean isFresh (File localFile, 
                String remoteFilePath)

Check local file's freshness. If local file is the same as remote file, then it's fresh. If not, local file is stale. This is mainly used for cache. The default implementation will always return true, so if the file is immutable it will never need to check freshness.

Parameters
localFile File: local file.

remoteFilePath String: remote file path.

Returns
boolean True if local file is fresh, otherwise false.

Throws
com.android.tradefed.build.BuildRetrievalError
BuildRetrievalError

releaseDownloadPermit

public void releaseDownloadPermit ()

If concurrency limit is supported, release a download permit.